aboutsummaryrefslogtreecommitdiff
path: root/gg.c
diff options
context:
space:
mode:
authorOmar Polo <op@omarpolo.com>2021-01-23 17:43:04 +0000
committerOmar Polo <op@omarpolo.com>2021-01-23 17:43:04 +0000
commitf62aab517ddf73e0e5ea09452dab58f73315b2c8 (patch)
treef32ff171bee49efb1a2cd75f28cc537328089f5a /gg.c
parent2349b02b261cabf5a95215f24550c454712066f6 (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.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/gg.c b/gg.c
index c8b40bb..b126cca 100644
--- a/gg.c
+++ b/gg.c
@@ -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);