diff options
author | Laurent Bercot <ska-skaware@skarnet.org> | 2020-11-26 00:39:05 +0000 |
---|---|---|
committer | Laurent Bercot <ska-skaware@skarnet.org> | 2020-11-26 00:39:05 +0000 |
commit | 005fae888243b1a9c51c270a689f08699164ac1d (patch) | |
tree | 984a6c41b46b56336149c7bca87b000b8393f04a | |
parent | eb37f0151f49d80117b0e215b1524e71e9c85dde (diff) | |
download | s6-networking-005fae888243b1a9c51c270a689f08699164ac1d.tar.xz |
Fix engine exit condition for sbearssl
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | src/sbearssl/sbearssl_run.c | 9 |
2 files changed, 6 insertions, 4 deletions
@@ -32,5 +32,6 @@ /s6-tlsserver /s6-tlsc-io /s6-tlsd-io +/s6-ucspitlsc /s6-ucspitlsd /src/minidentd/mgetuid.c diff --git a/src/sbearssl/sbearssl_run.c b/src/sbearssl/sbearssl_run.c index 44dbe88..ad2b0ad 100644 --- a/src/sbearssl/sbearssl_run.c +++ b/src/sbearssl/sbearssl_run.c @@ -19,7 +19,7 @@ void sbearssl_run (br_ssl_engine_context *ctx, int *fds, tain_t const *tto, uint iopause_fd x[4] ; unsigned int xindex[4] ; int markedforflush = 0 ; - int handshake_notdone = 1 ; + int handshake_done = 0 ; if (ndelay_on(fds[0]) < 0 || ndelay_on(fds[1]) < 0 @@ -46,11 +46,11 @@ void sbearssl_run (br_ssl_engine_context *ctx, int *fds, tain_t const *tto, uint x[j].fd = fds[0] ; x[j].events = IOPAUSE_READ ; xindex[0] = j++ ; - if (handshake_notdone) + if (!handshake_done) { if (!(*cb)(ctx, cbarg)) strerr_diefu1sys(111, "post-handshake callback failed") ; - handshake_notdone = 0 ; + handshake_done = 1 ; } } else xindex[0] = 4 ; @@ -76,7 +76,8 @@ void sbearssl_run (br_ssl_engine_context *ctx, int *fds, tain_t const *tto, uint } else xindex[3] = 4 ; - if (!j) break ; + if (xindex[0] == 4 && xindex[1] == 4 && xindex[3] == 4 && handshake_done) break ; + tain_add_g(&deadline, fds[0] >= 0 && fds[2] >= 0 && state & (BR_SSL_SENDAPP | BR_SSL_RECVREC) ? tto : &tain_infinite_relative) ; r = iopause_g(x, j, &deadline) ; if (r < 0) strerr_diefu1sys(111, "iopause") ; |