diff options
-rw-r--r-- | driver.c | 2 | ||||
-rw-r--r-- | fetchmail.man | 10 | ||||
-rw-r--r-- | socket.c | 13 |
3 files changed, 13 insertions, 12 deletions
@@ -874,7 +874,7 @@ const struct method *proto; /* protocol method table */ /* open a socket to the mail server */ if ((sockfp = Socket(ctl->servername, - ctl->port ? ctl->port : protocol->port))<0) + ctl->port ? ctl->port : protocol->port)) == (FILE *)NULL) { perror("fetchmail, connecting to host"); ok = PS_SOCKET; diff --git a/fetchmail.man b/fetchmail.man index bfd6b387..7e78b80f 100644 --- a/fetchmail.man +++ b/fetchmail.man @@ -701,16 +701,6 @@ catch equivalences created by MX records). If it is an alias of the server, but the lookup fails due to network congestion or a crashed server, forwarding will not get done correctly. .PP -Under Linux, if fetchmail is run in daemon mode with the network -inaccessible, each poll leaves a socket allocated but in CLOSE state -(this is visible in netstat(1)'s output). For some reason, these -sockets aren't garbage-collected until \fIfetchmail\fR exits. When -whatever kernel table is involved fills up, fetchmail can no longer -run even if the network is up. This appears \fInot\fR to be a socket -leak in \fIfetchmail\fR, but rather some glitch or misfeature in the system -network code. To avoid this problem, fetchmail commits seppuku after -too many unsuccessful socket opens. -.PP Send comments, bug reports, gripes, and the like to Eric S. Raymond <esr@thyrsus.com>. .SH SEE ALSO @@ -51,8 +51,19 @@ int clientPort; sock = socket(AF_INET, SOCK_STREAM, 0); if (sock < 0) return (FILE *)NULL; - if (connect(sock, (struct sockaddr *) &ad, sizeof(ad)) < 0) + + /* + * Return of connect(2) doesn't seem to reliably return -1 on + * ENETUNREACH failure + */ + errno = 0; + connect(sock, (struct sockaddr *) &ad, sizeof(ad)); + if (errno != 0); + { + close(sock); return (FILE *)NULL; + } + return fdopen(sock, "r+"); } |