commit - 2ff1e2a9237514d5d473b2b3562ec767542b55bc
commit + 800aa93c05250a0482e1767897cb80e3b52f0d07
blob - 54fb280b4af16cd6f9a5da79744be04d161aef67
blob + d8508f22803de11a56479d84f57921e0489879e4
--- gg.c
+++ gg.c
len = dorep(ctx, buf, sizeof(buf));
if (len == 0)
- goto close;
+ break;
if (foundhdr) {
write(1, buf, len);
if (debug == DEBUG_CODE) {
printf("%d\n", code);
- goto close;
+ break;
}
if (debug == DEBUG_HEADER) {
assert(t != NULL);
*t = '\0';
printf("%s\n", buf);
- goto close;
+ break;
}
if (debug == DEBUG_META) {
assert(t != NULL);
*t = '\0';
printf("%s\n", buf+3);
- goto close;
+ break;
}
if (debug == DEBUG_ALL) {
write(1, t, len);
}
-close:
- od = tls_close(ctx);
- if (od == TLS_WANT_POLLIN || od == TLS_WANT_POLLOUT)
- goto close;
-
- tls_close(ctx);
- tls_free(ctx);
- return code;
+ for (;;) {
+ switch (tls_close(ctx)) {
+ case TLS_WANT_POLLIN:
+ case TLS_WANT_POLLOUT:
+ continue;
+ case -1:
+ warnx("tls_close: %s", tls_error(ctx));
+ /* fallthrough */
+ default:
+ tls_free(ctx);
+ return code;
+ }
+ }
}
static void __attribute__((noreturn))