summaryrefslogtreecommitdiff
path: root/src/sbearssl
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2023-11-19 03:05:39 +0000
committerLaurent Bercot <ska@appnovation.com>2023-11-19 03:05:39 +0000
commit8fe924c3da6ab919f512029a15464e77cbeede8a (patch)
tree2b66be3ffe064f98621f8d2c10214a3e001ca19f /src/sbearssl
parent06b1f4f397d53e9a4c9abe4c8c4c20a7240e7736 (diff)
downloads6-networking-8fe924c3da6ab919f512029a15464e77cbeede8a.tar.xz
Small bugfixes, update deps, update doc
Signed-off-by: Laurent Bercot <ska@appnovation.com>
Diffstat (limited to 'src/sbearssl')
-rw-r--r--src/sbearssl/sbearssl_run.c15
1 files changed, 6 insertions, 9 deletions
diff --git a/src/sbearssl/sbearssl_run.c b/src/sbearssl/sbearssl_run.c
index 9f59302..af8b10e 100644
--- a/src/sbearssl/sbearssl_run.c
+++ b/src/sbearssl/sbearssl_run.c
@@ -33,20 +33,19 @@ void sbearssl_run (br_ssl_engine_context *ctx, int *fd, tain const *tto, uint32_
int handshake_done = 0 ;
int closing = 0 ;
tain deadline ;
+ tain_add_g(&deadline, tto) ;
if (ndelay_on(fd[0]) == -1
|| ndelay_on(fd[1]) == -1
|| ndelay_on(fd[2]) == -1
|| ndelay_on(fd[3]) == -1)
strerr_diefu1sys(111, "set fds non-blocking") ;
- tain_add_g(&deadline, tto) ;
- while (fd[0] >= 0 || fd[1] >= 0 || fd[3] >= 0)
+ while ((fd[0] >= 0 || fd[1] >= 0 || fd[3] >= 0) && !(state & BR_SSL_CLOSED))
{
uint8_t y[4] ;
uint8_t j = 0 ;
-
/* Preparation */
if (fd[0] >= 0 && state & BR_SSL_SENDAPP)
@@ -64,10 +63,10 @@ void sbearssl_run (br_ssl_engine_context *ctx, int *fd, tain const *tto, uint32_
}
else y[0] = 4 ;
- if (fd[1] >= 0 && state & BR_SSL_RECVAPP)
+ if (fd[1] >= 0)
{
x[j].fd = fd[1] ;
- x[j].events = IOPAUSE_WRITE ;
+ x[j].events = state & BR_SSL_RECVAPP ? IOPAUSE_WRITE : 0 ;
y[1] = j++ ;
}
else y[1] = 4 ;
@@ -80,16 +79,14 @@ void sbearssl_run (br_ssl_engine_context *ctx, int *fd, tain const *tto, uint32_
}
else y[2] = 4 ;
- if (fd[3] >= 0 && state & BR_SSL_SENDREC)
+ if (fd[3] >= 0)
{
x[j].fd = fd[3] ;
- x[j].events = IOPAUSE_WRITE ;
+ x[j].events = state & BR_SSL_SENDREC ? IOPAUSE_WRITE : 0 ;
y[3] = j++ ;
}
else y[3] = 4 ;
- if (!j) break ;
-
/* Wait for events */
switch (iopause_g(x, j, &deadline))