[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 2/3] pkd_daemon.c: split final close loop; wait for client to close
[Thread Prev] | [Thread Next]
- Subject: [PATCH 2/3] pkd_daemon.c: split final close loop; wait for client to close
- From: Jon Simons <jon@xxxxxxxxxxxxx>
- Reply-to: libssh@xxxxxxxxxx
- Date: Sat, 9 Sep 2017 20:12:34 -0700
- To: libssh@xxxxxxxxxx
- Cc: Jon Simons <jon@xxxxxxxxxxxxx>
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@xxxxxxxxxxxxx> --- 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: -- 2.14.1
[PATCH 0/3] pkd: fix return code check and some races | Jon Simons <jon@xxxxxxxxxxxxx> |