public inbox for git@vger.kernel.org 
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox•com>
To: Phillip Wood <phillip.wood123@gmail•com>
Cc: "Carlo Marcelo Arenas Belón" <carenas@gmail•com>,
	git@vger•kernel.org, yoshfuji@linux-ipv6•org,
	kristofferhaugsbakk@fastmail•com
Subject: Re: [PATCH v3] daemon: correctly handle soft accept() errors in service_loop
Date: Mon, 30 Jun 2025 08:33:31 -0700	[thread overview]
Message-ID: <xmqqv7od452s.fsf@gitster.g> (raw)
In-Reply-To: <0d507273-8b8c-42d9-a14f-27a5da0dac27@gmail.com> (Phillip Wood's message of "Mon, 30 Jun 2025 10:00:17 +0100")

Phillip Wood <phillip.wood123@gmail•com> writes:

> Hi Carlo
>
> This looks good
>
> Thanks
>
> Phillip

Thanks, both of you.  Shall we mark the topic for 'next', then?


> On 28/06/2025 00:14, Carlo Marcelo Arenas Belón wrote:
>> 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 to retry with the same listener socket that failed
>> originally.
>> To avoid an unlikely 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 | 12 ++++++++++--
>>   1 file changed, 10 insertions(+), 2 deletions(-)
>> diff --git a/daemon.c b/daemon.c
>> index d1be61fd57..9ac9efa17c 100644
>> --- a/daemon.c
>> +++ b/daemon.c
>> @@ -1153,11 +1153,19 @@ 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;
>> +				int retry = 3;
>> +
>> +			redo:
>> +				incoming = accept(pfd[i].fd, &ss.sa, &sslen);
>>   				if (incoming < 0) {
>>   					switch (errno) {
>> -					case EAGAIN:
>>   					case EINTR:
>> +						if (--retry)
>> +							goto redo;
>> +
>> +						/* fallthrough */
>> +					case EAGAIN:
>>   					case ECONNABORTED:
>>   						continue;
>>   					default:

  reply	other threads:[~2025-06-30 15:33 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
2025-07-01 19:33         ` Phillip Wood

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xmqqv7od452s.fsf@gitster.g \
    --to=gitster@pobox$(echo .)com \
    --cc=carenas@gmail$(echo .)com \
    --cc=git@vger$(echo .)kernel.org \
    --cc=kristofferhaugsbakk@fastmail$(echo .)com \
    --cc=phillip.wood123@gmail$(echo .)com \
    --cc=yoshfuji@linux-ipv6$(echo .)org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox