From: Egor Date: Wed, 11 May 2022 20:55:42 +0000 (+0300) Subject: sendClient: exit when write returns 0 X-Git-Url: https://git.patchysicp.xyz/?a=commitdiff_plain;h=e646d22040c54855eb826167db96a4040062fca2;p=patchyircd.git sendClient: exit when write returns 0 --- 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;