* [RFC PATCH 1B] credential-cache--daemon: close input before exit-ing
@ 2022-07-07 1:54 Ramsay Jones
2022-07-07 13:00 ` Ævar Arnfjörð Bjarmason
0 siblings, 1 reply; 3+ messages in thread
From: Ramsay Jones @ 2022-07-07 1:54 UTC (permalink / raw)
To: Adam Dinwoodie; +Cc: GIT Mailing-list
Signed-off-by: Ramsay Jones <ramsay@ramsayjones.plus.com>
---
builtin/credential-cache--daemon.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/builtin/credential-cache--daemon.c b/builtin/credential-cache--daemon.c
index 4c6c89ab0d..556393498f 100644
--- a/builtin/credential-cache--daemon.c
+++ b/builtin/credential-cache--daemon.c
@@ -138,6 +138,7 @@ static void serve_one_client(FILE *in, FILE *out)
* process actually ends, which closes the socket and gives
* them EOF.
*/
+ fclose(in);
exit(0);
}
else if (!strcmp(action.buf, "erase"))
--
2.37.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [RFC PATCH 1B] credential-cache--daemon: close input before exit-ing
2022-07-07 1:54 [RFC PATCH 1B] credential-cache--daemon: close input before exit-ing Ramsay Jones
@ 2022-07-07 13:00 ` Ævar Arnfjörð Bjarmason
2022-07-07 15:35 ` Ramsay Jones
0 siblings, 1 reply; 3+ messages in thread
From: Ævar Arnfjörð Bjarmason @ 2022-07-07 13:00 UTC (permalink / raw)
To: Ramsay Jones; +Cc: Adam Dinwoodie, GIT Mailing-list
On Thu, Jul 07 2022, Ramsay Jones wrote:
> Signed-off-by: Ramsay Jones <ramsay@ramsayjones.plus.com>
> ---
> builtin/credential-cache--daemon.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/builtin/credential-cache--daemon.c b/builtin/credential-cache--daemon.c
> index 4c6c89ab0d..556393498f 100644
> --- a/builtin/credential-cache--daemon.c
> +++ b/builtin/credential-cache--daemon.c
> @@ -138,6 +138,7 @@ static void serve_one_client(FILE *in, FILE *out)
> * process actually ends, which closes the socket and gives
> * them EOF.
> */
> + fclose(in);
> exit(0);
> }
> else if (!strcmp(action.buf, "erase"))
This is called by a function that will also close stdout, shouldn't we
be closing it here?
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [RFC PATCH 1B] credential-cache--daemon: close input before exit-ing
2022-07-07 13:00 ` Ævar Arnfjörð Bjarmason
@ 2022-07-07 15:35 ` Ramsay Jones
0 siblings, 0 replies; 3+ messages in thread
From: Ramsay Jones @ 2022-07-07 15:35 UTC (permalink / raw)
To: Ævar Arnfjörð Bjarmason
Cc: Adam Dinwoodie, GIT Mailing-list, Jeff King
On 07/07/2022 14:00, Ævar Arnfjörð Bjarmason wrote:
>
> On Thu, Jul 07 2022, Ramsay Jones wrote:
>
>> Signed-off-by: Ramsay Jones <ramsay@ramsayjones.plus.com>
>> ---
>> builtin/credential-cache--daemon.c | 1 +
>> 1 file changed, 1 insertion(+)
>>
>> diff --git a/builtin/credential-cache--daemon.c b/builtin/credential-cache--daemon.c
>> index 4c6c89ab0d..556393498f 100644
>> --- a/builtin/credential-cache--daemon.c
>> +++ b/builtin/credential-cache--daemon.c
>> @@ -138,6 +138,7 @@ static void serve_one_client(FILE *in, FILE *out)
>> * process actually ends, which closes the socket and gives
>> * them EOF.
>> */
>> + fclose(in);
>> exit(0);
>> }
>> else if (!strcmp(action.buf, "erase"))
>
> This is called by a function that will also close stdout, shouldn't we
> be closing it here?
Err, do you mean 'out' rather than 'stdout'? Actually, it doesn't
matter either way! :)
Let me quote from [1], which (hopefully) explains the context:
"""
Anyway, I started playing around with flushing/closing of 'FILE *' streams
before the 'exit' call, to change the order, relative to the socket-file
deletion in the 'atexit' function (or the closing of the listen-socket
descriptor, come to that). In particular, I found that if I were to close
the 'in'put stream, then the client would receive an EOF and exit normally
(ie no error return from read_in_full() above).
[fclose(in); fclose(out) also works, but fclose(out) on its own does not.
fflush() in various combinations did not work at all].
"""
So, my intent was to find the _minimum_ change necessary to fix the test.
This is not a 'real' patch - it was only to demonstrate that there appears
to be some order dependency problem induced by the 'atexit' clean-up from
exit()-ing the server.
ATB,
Ramsay Jones
[1] https://lore.kernel.org/git/9dc3e85f-a532-6cff-de11-1dfb2e4bc6b6@ramsayjones.plus.com/
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-07-07 15:35 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-07 1:54 [RFC PATCH 1B] credential-cache--daemon: close input before exit-ing Ramsay Jones
2022-07-07 13:00 ` Ævar Arnfjörð Bjarmason
2022-07-07 15:35 ` Ramsay Jones
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).