Skip to content

Commit 485c7ad

Browse files
committed
Merge branch 'jk/credential-cache-comment-exit' into maint
A code clarification. * jk/credential-cache-comment-exit: credential-cache--daemon: clarify "exit" action semantics
2 parents 1d1cbe2 + 7d5e9c9 commit 485c7ad

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

credential-cache--daemon.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,17 @@ static void serve_one_client(FILE *in, FILE *out)
126126
fprintf(out, "password=%s\n", e->item.password);
127127
}
128128
}
129-
else if (!strcmp(action.buf, "exit"))
129+
else if (!strcmp(action.buf, "exit")) {
130+
/*
131+
* It's important that we clean up our socket first, and then
132+
* signal the client only once we have finished the cleanup.
133+
* Calling exit() directly does this, because we clean up in
134+
* our atexit() handler, and then signal the client when our
135+
* process actually ends, which closes the socket and gives
136+
* them EOF.
137+
*/
130138
exit(0);
139+
}
131140
else if (!strcmp(action.buf, "erase"))
132141
remove_credential(&c);
133142
else if (!strcmp(action.buf, "store")) {

0 commit comments

Comments
 (0)