aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--driver.c2
-rw-r--r--fetchmail.man10
-rw-r--r--socket.c13
3 files changed, 13 insertions, 12 deletions
diff --git a/driver.c b/driver.c
index 84e557f3..1c8408e1 100644
--- a/driver.c
+++ b/driver.c
@@ -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
diff --git a/socket.c b/socket.c
index f0020adf..9d716dcb 100644
--- a/socket.c
+++ b/socket.c
@@ -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+");
}