[tin-dev] fix for debian bug #232924 not very informative connect error for rtin
Urs Janßen
urs at tin.org
Mon Dec 3 19:51:21 CET 2018
<https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=232924>
=== modified file 'src/nntplib.c'
--- src/nntplib.c 2018-05-14 13:12:56 +0000
+++ src/nntplib.c 2018-12-03 18:48:11 +0000
@@ -592,7 +592,7 @@
{
char mymachine[MAXHOSTNAMELEN + 1];
char myport[12];
- int s = -1, err;
+ int s = -1, err, ec = 0, es = 0;
struct addrinfo hints, *res, *res0;
snprintf(mymachine, sizeof(mymachine), "%s", machine);
@@ -619,22 +619,28 @@
}
err = -1;
for (res = res0; res; res = res->ai_next) {
- if ((s = socket(res->ai_family, res->ai_socktype, res->ai_protocol)) < 0)
+ if ((s = socket(res->ai_family, res->ai_socktype, res->ai_protocol)) < 0) {
+ es = errno;
continue;
- if (connect(s, res->ai_addr, res->ai_addrlen) != 0)
+ }
+ if (connect(s, res->ai_addr, res->ai_addrlen) != 0) {
+ ec = errno;
s_close(s);
+ }
else {
- err = 0;
+ es = ec = err = 0;
break;
}
}
if (res0 != NULL)
freeaddrinfo(res0);
if (err < 0) {
- /*
- * TODO: issue a more useful error-message
- */
my_fprintf(stderr, "%s", _(txt_error_socket_or_connect_problem));
+ if (es)
+ my_fprintf(stderr, "\tsocket(2): %s\n", strerror(es));
+ if (ec)
+ my_fprintf(stderr, "\tconnect(2): %s\n", strerror(ec));
+ sleep(3);
return -1;
}
return s;
More information about the tin-dev
mailing list