]> git.ipfire.org Git - thirdparty/git.git/commitdiff
Merge branch 'ew/daemon-socket-keepalive' into maint
authorJunio C Hamano <gitster@pobox.com>
Mon, 8 Aug 2016 21:21:37 +0000 (14:21 -0700)
committerJunio C Hamano <gitster@pobox.com>
Mon, 8 Aug 2016 21:21:37 +0000 (14:21 -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 9a8803b876a1ed38aca34e83c3859e607bdd17e7..ef22cbb05d140a210bd348ea1234fc60cdf09da8 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 46dddaca5a05a4d50da21c828085168e3ebe8b86..a84495113e4c4e85243937ad0306a17981003c7b 100644 (file)
--- a/daemon.c
+++ b/daemon.c
@@ -673,9 +673,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)