/* 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;
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
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+");
}