diff options
author | Jon Simons <jon@jonsimons.org> | 2017-09-09 20:12:34 -0700 |
---|---|---|
committer | Andreas Schneider <asn@cryptomilk.org> | 2017-09-11 16:30:54 +0200 |
commit | 8d7563a9c3a02a05e09950cc5445d2c6bc2fc9aa (patch) | |
tree | 62b42560a1d4e0bf546638f7b5a4148a3c563ff9 /tests/pkd | |
parent | 4c4a03f056724c59def75b4d3332014b5ef0e9f2 (diff) | |
download | libssh-8d7563a9c3a02a05e09950cc5445d2c6bc2fc9aa.tar.gz libssh-8d7563a9c3a02a05e09950cc5445d2c6bc2fc9aa.tar.xz libssh-8d7563a9c3a02a05e09950cc5445d2c6bc2fc9aa.zip |
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>
Diffstat (limited to 'tests/pkd')
-rw-r--r-- | tests/pkd/pkd_daemon.c | 14 |
1 files 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: |