git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] daemon: correctly handle soft accept() errors
@ 2025-06-26 16:10 Carlo Marcelo Arenas Belón
  2025-06-26 16:15 ` Kristoffer Haugsbakk
  2025-06-26 17:21 ` [PATCH v2] daemon: correctly handle soft accept() errors in service_loop Carlo Marcelo Arenas Belón
  0 siblings, 2 replies; 14+ messages in thread
From: Carlo Marcelo Arenas Belón @ 2025-06-26 16:10 UTC (permalink / raw)
  To: git; +Cc: YOSHIFUJI Hideaki, Carlo Marcelo Arenas Belón

Since df076bdbcc ([PATCH] GIT: Listen on IPv6 as well, if available.,
2005-07-23), the original error checking was included in an inner loop
unchanged, where its effect was different.

Instead of retrying, after a EINTR during accept() in the listening
socket, it will advance to the next one and try with that instead,
leaving the client waiting for another round.

Make sure that the loop doesn't advance and while at it, make sure
that any possible completed childs get reaped earlier. To avoid an
unlilely busy loop, fallback to the old behaviour after a couple
of attempts.

Signed-off-by: Carlo Marcelo Arenas Belón <carenas@gmail.com>
---
 daemon.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/daemon.c b/daemon.c
index d1be61fd57..8d02099a4e 100644
--- a/daemon.c
+++ b/daemon.c
@@ -1153,11 +1153,21 @@ static int service_loop(struct socketlist *socklist)
 #endif
 				} ss;
 				socklen_t sslen = sizeof(ss);
-				int incoming = accept(pfd[i].fd, &ss.sa, &sslen);
+				int incoming;
+
+redo:
+				incoming = accept(pfd[i].fd, &ss.sa, &sslen);
 				if (incoming < 0) {
+					int retry = 2;
+
 					switch (errno) {
-					case EAGAIN:
 					case EINTR:
+						if (--retry) {
+							check_dead_children();
+							goto redo;
+						}
+						/* fallthrough */
+					case EAGAIN:
 					case ECONNABORTED:
 						continue;
 					default:
-- 
2.50.0.132.gb7f585ac00


^ permalink raw reply related	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2025-07-01 19:33 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-26 16:10 [PATCH] daemon: correctly handle soft accept() errors Carlo Marcelo Arenas Belón
2025-06-26 16:15 ` Kristoffer Haugsbakk
2025-06-26 17:21 ` [PATCH v2] daemon: correctly handle soft accept() errors in service_loop Carlo Marcelo Arenas Belón
2025-06-27  8:38   ` Phillip Wood
2025-06-27 19:05     ` Carlo Marcelo Arenas Belón
2025-06-27 20:19       ` Junio C Hamano
2025-06-27 23:05         ` Carlo Marcelo Arenas Belón
2025-06-27 23:25           ` Hridoy Ahmed
2025-06-27 23:53           ` Junio C Hamano
2025-06-30  8:59             ` Phillip Wood
2025-06-27 23:14   ` [PATCH v3] " Carlo Marcelo Arenas Belón
2025-06-30  9:00     ` Phillip Wood
2025-06-30 15:33       ` Junio C Hamano
2025-07-01 19:33         ` Phillip Wood

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).