credential-cache--daemon: make exit action follow timeout exit
RFC PATCH 1/1 credential-cache--daemon: make exit action follow timeout exit
Signed-off-by Ramsay Jones <[email protected]>
--- builtin/credential-cache--daemon.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-)
builtin/credential-cache--daemon.c +8 -11
@@ -114,11 +114,12 @@ static int read_request(FILE *fh, struct credential *c,return 0 ; } -static void serve_one_client (FILE *in,FILE *out) +static int serve_one_client (FILE *in,FILE *out) {struct credential c =CREDENTIAL_INIT ;struct strbuf action =STRBUF_INIT ;int timeout =-1 ; +int serve =1 ;/* ie continue to serve clients */ if (read_request (in, &c, &action, &timeout) <0 )/* ignore error */ ;
@@ -130,15 +131,8 @@ static void serve_one_client(FILE *in, FILE *out) } }else if (!strcmp (action.buf,"exit" )) { -/* -* It's important that we clean up our socket first, and then -* signal the client only once we have finished the cleanup. -* Calling exit() directly does this, because we clean up in -* our atexit() handler, and then signal the client when our -* process actually ends, which closes the socket and gives -* them EOF. -*/ -exit (0 ); +/* stop serving clients */ + serve =0 ; }else if (!strcmp (action.buf,"erase" ))remove_credential (&c);
@@ -157,6 +151,7 @@ static void serve_one_client(FILE *in, FILE *out)credential_clear (&c);strbuf_release (&action); +return serve; }static int serve_cache_loop (int fd)
@@ -179,6 +174,7 @@ static int serve_cache_loop(int fd)if (pfd.revents &POLLIN ) {int client, client2;FILE *in, *out; +int serve; client =accept (fd,NULL ,NULL );if (client <0 ) {
@@ -194,9 +190,10 @@ static int serve_cache_loop(int fd) in =xfdopen (client,"r" ); out =xfdopen (client2,"w" ); -serve_one_client (in, out); + serve =serve_one_client (in, out);fclose (in);fclose (out); +return serve; }return 1 ; }
Signature · 1 line
2.37.0