Skip to content

Commit 172b811

Browse files
committed
Merge branch 'ew/daemon-socket-keepalive' into maint
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
2 parents aa9136a + fab6027 commit 172b811

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

compat/mingw.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,9 @@ typedef int pid_t;
7373
#ifndef ECONNABORTED
7474
#define ECONNABORTED WSAECONNABORTED
7575
#endif
76+
#ifndef ENOTSOCK
77+
#define ENOTSOCK WSAENOTSOCK
78+
#endif
7679

7780
struct passwd {
7881
char *pw_name;

daemon.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -673,9 +673,11 @@ static void set_keep_alive(int sockfd)
673673
{
674674
int ka = 1;
675675

676-
if (setsockopt(sockfd, SOL_SOCKET, SO_KEEPALIVE, &ka, sizeof(ka)) < 0)
677-
logerror("unable to set SO_KEEPALIVE on socket: %s",
678-
strerror(errno));
676+
if (setsockopt(sockfd, SOL_SOCKET, SO_KEEPALIVE, &ka, sizeof(ka)) < 0) {
677+
if (errno != ENOTSOCK)
678+
logerror("unable to set SO_KEEPALIVE on socket: %s",
679+
strerror(errno));
680+
}
679681
}
680682

681683
static int execute(void)

0 commit comments

Comments
 (0)