From e646d22040c54855eb826167db96a4040062fca2 Mon Sep 17 00:00:00 2001 From: Egor Date: Wed, 11 May 2022 23:55:42 +0300 Subject: [PATCH] sendClient: exit when write returns 0 --- net.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/net.c b/net.c index 315c55b..86aefce 100644 --- a/net.c +++ b/net.c @@ -137,6 +137,8 @@ void sendClient(struct client_data *cl, const char *buf, size_t len) if (cl->cctx) { while (len) { int rv = tls_write(cl->cctx, buf, len); + if (!rv) + break; if (rv == -1) break; if (rv == TLS_WANT_POLLIN || rv == TLS_WANT_POLLOUT) @@ -149,6 +151,8 @@ void sendClient(struct client_data *cl, const char *buf, size_t len) { while (len) { int rv = send(cl->FD, buf, len, 0); + if (!rv) + break; if (rv == -1) { if (net_wouldblock()) continue; -- 2.56.0