]> PatchyGit - patchyircd.git/commitdiff
net: add proper blocking for non-tls
authorEgor <egor@patchysicp.xyz>
Wed, 27 Sep 2023 23:04:46 +0000 (02:04 +0300)
committerEgor <egor@patchysicp.xyz>
Wed, 27 Sep 2023 23:04:46 +0000 (02:04 +0300)
net.c

diff --git a/net.c b/net.c
index a6601cb..e333c89 100644 (file)
--- a/net.c
+++ b/net.c
@@ -78,7 +78,6 @@ void killConnection(struct client_data *cl, bool byChoice) {
        free(cl);
 }
 
-#if HAS_TLS
 static void block(struct client_data *cl, int out)
 {
 #ifdef _WIN32
@@ -96,7 +95,6 @@ static void block(struct client_data *cl, int out)
        poll(&pfd, 1, 0);
 #endif
 }
-#endif
 
 void recvProc(struct client_data *cl) {
        ssize_t bytesRead;
@@ -188,10 +186,12 @@ void sendClient(struct client_data *cl, const char *buf, size_t len)
                        if (!rv)
                                break;
                        if (rv == -1) {
-                               if (net_wouldblock())
+                               if (net_wouldblock()) {
+                                       block(cl, 1);
                                        continue;
-                               else
+                               } else {
                                        break;
+                               }
                        }
                        buf += rv;
                        len -= rv;