From 8d7563a9c3a02a05e09950cc5445d2c6bc2fc9aa Mon Sep 17 00:00:00 2001 From: Jon Simons Date: Sat, 9 Sep 2017 20:12:34 -0700 Subject: [PATCH] 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 Reviewed-by: Andreas Schneider --- tests/pkd/pkd_daemon.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/tests/pkd/pkd_daemon.c b/tests/pkd/pkd_daemon.c index 44cd0ce3..3a530793 100644 --- a/tests/pkd/pkd_daemon.c +++ b/tests/pkd/pkd_daemon.c @@ -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: