Skip to contentSkip to conversation

daemon.c: squelch error message from EINTR

PATCH In review Junio C Hamano 2 participants 2 messages Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 daemon.c: squelch error message from EINTR

This is a "call for help" patch. The kernel.org folks are talking about installing git daemon, and while the problem I am trying to address should not matter when the daemon is spawned from inetd, I would like to get this resolved. Help greatly apprciated.

-jc

------------
It appears that every time after servicing the connection, select() first fails with EINTR and ends up waiting for one second before serving the next client. The sleep() was placed by the original author per suggestion from the list to avoid spinning on failing select, but at least this EINTR situation should not result in "at most one client per second" service limit.

I am not sure if this is the right fix, and I have not received an answer from the original author of the patch. I would appreciate help from the folks on the list who are familiar with the networking.

---

 daemon.c |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)

34be43e7af874923cfa1c8baeaf19fa17bae4d30

daemon.c +5 -2
@@ -294,8 +294,11 @@ static int serve(int port)
 		fds = fds_init;
 		
 		if (select(maxfd + 1, &fds, NULL, NULL, NULL) < 0) {
-			error("select failed, resuming: %s", strerror(errno));
-			sleep(1);
+			if (errno != EINTR) {
+				error("select failed, resuming: %s",
+				      strerror(errno));
+				sleep(1);
+			}
 			continue;
 		}
 
#1 lore raw

Dear diary, on Wed, Aug 03, 2005 at 08:20:01AM CEST, I got a letter where Junio C Hamano <[email protected]> told me that...

Quoted 4 lines

I am not sure if this is the right fix, and I have not received an answer from the original author of the patch. I would appreciate help from the folks on the list who are familiar with the networking.

I think it's fine. EINTR means it got a signal while waiting, it might be worthwhile checking by strace what signal it actually was - one thing coming on my mind is SIGPIPE or so, but I barely saw the code. Anyway, just sticking your hand in sand if you see this is probably fine.

Signature · 4 lines
				Petr "Pasky" Baudis
Stuff: http://pasky.or.cz/
If you want the holes in your knowledge showing up try teaching
someone.  -- Alan Cox