Skip to content

Commit b48dfd8

Browse files
committed
Merge branch 'ew/daemon-socket-keepalive'
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 ad2d777 + fab6027 commit b48dfd8

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
@@ -672,9 +672,11 @@ static void set_keep_alive(int sockfd)
672672
{
673673
int ka = 1;
674674

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

680682
static int execute(void)

0 commit comments

Comments
 (0)