diff options
author | Omar Polo <op@omarpolo.com> | 2021-01-23 17:43:04 +0000 |
---|---|---|
committer | Omar Polo <op@omarpolo.com> | 2021-01-23 17:43:04 +0000 |
commit | f62aab517ddf73e0e5ea09452dab58f73315b2c8 (patch) | |
tree | f32ff171bee49efb1a2cd75f28cc537328089f5a /gg.c | |
parent | 2349b02b261cabf5a95215f24550c454712066f6 (diff) |
handle TLS_WANT_POLL{IN,OUT}
libtls doesn't seem to return when doing blocking I/O, but libretls
does every single time.
Diffstat (limited to 'gg.c')
-rw-r--r-- | gg.c | 12 |
1 files changed, 9 insertions, 3 deletions
@@ -112,9 +112,14 @@ main(int argc, char **argv) /* errx(1, "tls_write: %s", tls_error(ctx)); */ for (;;) { - len = tls_read(ctx, buf, sizeof(buf)); - if (len == 0 || len == -1) - break; + switch (len = tls_read(ctx, buf, sizeof(buf))) { + case 0: + case -1: + goto end; + case TLS_WANT_POLLIN: + case TLS_WANT_POLLOUT: + continue; + } if (bflag) { bflag = 0; @@ -148,6 +153,7 @@ main(int argc, char **argv) write(1, buf, len); } +end: tls_close(ctx); tls_free(ctx); |