Merge branch 'ew/daemon-socket-keepalive'
authorJunio C Hamano <gitster@pobox.com>
Thu, 28 Jul 2016 17:34:43 +0000 (10:34 -0700)
committerJunio C Hamano <gitster@pobox.com>
Thu, 28 Jul 2016 17:34:43 +0000 (10:34 -0700)
Recent update to "git daemon" tries to enable the socket-level
KEEPALIVE, but when it is spawned via inetd, the standard input
file descriptor may not necessarily be connected to a socket.
Suppress an ENOTSOCK error from setsockopt().

* ew/daemon-socket-keepalive:
Windows: add missing definition of ENOTSOCK
daemon: ignore ENOTSOCK from setsockopt

compat/mingw.h
daemon.c
index 233933ee86b2d069c7fca5b0dc39ea6c6badb20b..95e128fcfd45e98c091256265c7d9bda95ec733f 100644 (file)
@@ -73,6 +73,9 @@ typedef int pid_t;
 #ifndef ECONNABORTED
 #define ECONNABORTED WSAECONNABORTED
 #endif
+#ifndef ENOTSOCK
+#define ENOTSOCK WSAENOTSOCK
+#endif
 
 struct passwd {
        char *pw_name;
index e647254c196f8270691cd369b51ac5132add1259..425aad0507f48ca07b11faa05828ea841bdd302f 100644 (file)
--- a/daemon.c
+++ b/daemon.c
@@ -672,9 +672,11 @@ static void set_keep_alive(int sockfd)
 {
        int ka = 1;
 
-       if (setsockopt(sockfd, SOL_SOCKET, SO_KEEPALIVE, &ka, sizeof(ka)) < 0)
-               logerror("unable to set SO_KEEPALIVE on socket: %s",
-                       strerror(errno));
+       if (setsockopt(sockfd, SOL_SOCKET, SO_KEEPALIVE, &ka, sizeof(ka)) < 0) {
+               if (errno != ENOTSOCK)
+                       logerror("unable to set SO_KEEPALIVE on socket: %s",
+                               strerror(errno));
+       }
 }
 
 static int execute(void)