torrentd

simple torrent daemon
git clone git@git.2f30.org/torrentd.git
Log | Files | Refs | LICENSE

commit eeff5cd86ab8f4a719fec00ab007ab486ff030d8
parent c7baa3393f410966076c659f9a1dac77f8854471
Author: sin <sin@2f30.org>
Date:   Thu, 17 Dec 2015 17:08:18 +0000

Don't kill the process if dial() fails

Diffstat:
Msock.c | 13++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/sock.c b/sock.c @@ -32,8 +32,10 @@ dial(char *host, char *port) memset(&hints, 0, sizeof(hints)); hints.ai_family = AF_INET; hints.ai_socktype = SOCK_STREAM; - if (getaddrinfo(host, port, &hints, &res)) - errx(1, "can't resolve %s", host); + if (getaddrinfo(host, port, &hints, &res)) { + warnx("can't resolve %s", host); + return -1; + } for (r = res; r; r = r->ai_next) { s = socket(r->ai_family, r->ai_socktype, 0); if (s < 0) @@ -43,8 +45,9 @@ dial(char *host, char *port) close(s); } freeaddrinfo(res); - if (!r) - errx(1, "cannot connect to %s on port %s", - host, port); + if (!r) { + warnx("cannot connect to %s on port %s", host, port); + return -1; + } return s; }