]> PatchyGit - patchyircd.git/commitdiff
sendClient: exit when write returns 0
authorEgor <egor@patchysicp.xyz>
Wed, 11 May 2022 20:55:42 +0000 (23:55 +0300)
committerEgor <egor@patchysicp.xyz>
Wed, 11 May 2022 20:55:42 +0000 (23:55 +0300)
net.c

diff --git a/net.c b/net.c
index 315c55b..86aefce 100644 (file)
--- 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;