From 49c58d86ceb7816c5f0ca36e38e26cd6b8506d74 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Mon, 18 Jul 2016 04:59:11 +0000 Subject: [PATCH 1/2] daemon: ignore ENOTSOCK from setsockopt In inetd mode, we are not guaranteed stdin or stdout is a socket; callers could filter the data through a pipe or be testing with regular files. This prevents t5802 from polluting syslog. Signed-off-by: Eric Wong Signed-off-by: Junio C Hamano --- daemon.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/daemon.c b/daemon.c index 46dddaca5a..a84495113e 100644 --- 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) From fab60274800efba101b3f08a297639d14ecbf840 Mon Sep 17 00:00:00 2001 From: Johannes Sixt Date: Thu, 21 Jul 2016 22:59:06 +0200 Subject: [PATCH 2/2] Windows: add missing definition of ENOTSOCK The previous commit introduced the first use of ENOTSOCK. This macro is not available on Windows. Define it as WSAENOTSOCK because that is the corresponding error value reported by the Windows versions of socket functions. Signed-off-by: Johannes Sixt Signed-off-by: Junio C Hamano --- compat/mingw.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/compat/mingw.h b/compat/mingw.h index c008694639..7489d2980e 100644 --- a/compat/mingw.h +++ b/compat/mingw.h @@ -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;