mirror of
https://git.libssh.org/projects/libssh.git
synced 2026-02-04 12:20:42 +09:00
pkd_daemon.c: split final close loop; wait for client to close
Sometimes, but not always, the pkd tests will fail because they close the socket at hand a bit too early for the client. The client in turn may exit non-zero when that happens. Split up the final close loop so that pkd waits to receive a channel close from the client, and then socket close, before finally returning. With this change I observe that tests are now passing in environments that would previously tickle the above race and fail. Signed-off-by: Jon Simons <jon@jonsimons.org> Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
This commit is contained in:
committed by
Andreas Schneider
parent
4c4a03f056
commit
8d7563a9c3
@@ -364,8 +364,7 @@ static int pkd_exec_hello(int fd, struct pkd_daemon_args *args) {
|
||||
|
||||
while ((ctx.keep_going != 0) &&
|
||||
(pkd_state.eof_received == 0) &&
|
||||
(pkd_state.close_received == 0) &&
|
||||
(ssh_channel_is_closed(c) == 0)) {
|
||||
(pkd_state.close_received == 0)) {
|
||||
rc = ssh_event_dopoll(e, 1000 /* milliseconds */);
|
||||
if (rc == SSH_ERROR) {
|
||||
pkderr("ssh_event_dopoll for eof + close: %s\n", ssh_get_error(s));
|
||||
@@ -374,6 +373,17 @@ static int pkd_exec_hello(int fd, struct pkd_daemon_args *args) {
|
||||
rc = 0;
|
||||
}
|
||||
}
|
||||
|
||||
while ((ctx.keep_going != 0) &&
|
||||
(ssh_is_connected(s))) {
|
||||
rc = ssh_event_dopoll(e, 1000 /* milliseconds */);
|
||||
if (rc == SSH_ERROR) {
|
||||
pkderr("ssh_event_dopoll for session connection: %s\n", ssh_get_error(s));
|
||||
break;
|
||||
} else {
|
||||
rc = 0;
|
||||
}
|
||||
}
|
||||
goto out;
|
||||
|
||||
outclose:
|
||||
|
||||
Reference in New Issue
Block a user