]> Pileus Git - ~andy/fetchmail/commitdiff
SockOpen(): set SO_KEEPALIVE.
authorMatthias Andree <matthias.andree@gmx.de>
Fri, 13 May 2011 11:15:03 +0000 (13:15 +0200)
committerMatthias Andree <matthias.andree@gmx.de>
Fri, 13 May 2011 11:15:03 +0000 (13:15 +0200)
NEWS
socket.c

diff --git a/NEWS b/NEWS
index f6060ab1088debb064c0d13ffebd1ab0c8e3229b..a72157909ff3c6b275cea8893d12932160b8a45a 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -67,6 +67,9 @@ fetchmail-6.3.20 (not yet released):
 * fetchmail now supports an environment variable to suppress marking deleted
   messages as seen at the same time, FETCHMAIL_IMAP_DELETED_REMAINS_UNSEEN.
   See the manual page for details. Requested by Jonathan Buschmann.
+* fetchmail sets Internet domain sockets to "keepalive" mode now. Note that
+  there is no portable way to configure actual timeouts for this mode, and some
+  systems only support a system-wide timeout setting.
 
 # BUG FIXES
 * Call strlen() only once when removing CRLF from a line. (Sunil Shetye)
index 930e1b0d7896dd9392ec329f230ca2589d1c743e..5573b4eef2b9cafdea3f6eba6c21ebd8e9c22a5d 100644 (file)
--- a/socket.c
+++ b/socket.c
@@ -225,6 +225,12 @@ int SockTimeout(int sock, int timeout)
     return err;
 }
 
+/** Set socket to SO_KEEPALIVE. \return 0 for success. */
+int SockKeepalive(int sock) {
+    int keepalive = 1;
+    return setsockopt(sock, SOL_SOCKET, SO_KEEPALIVE, &keepalive, sizeof keepalive);
+}
+
 int UnixOpen(const char *path)
 {
     int sock = -1;
@@ -319,6 +325,9 @@ int SockOpen(const char *host, const char *service,
            continue;
        }
 
+       SockTimeout(i, mytimeout);
+       SockKeepalive(i);
+
        /* Save socket descriptor.
         * Used to close the socket after connect timeout. */
        mailserver_socket_temp = i;