]> PatchyGit - patchyircd.git/commitdiff
check EAGAIN/EWOULDBLOCK directly
authorEgor <egor@patchysicp.xyz>
Fri, 13 Jun 2025 00:40:42 +0000 (03:40 +0300)
committerEgor <egor@patchysicp.xyz>
Fri, 13 Jun 2025 01:18:16 +0000 (04:18 +0300)
src/main.cpp
src/net.cpp
src/netsock.h

index 28e56ab..a979e4e 100644 (file)
@@ -72,7 +72,7 @@ static void accept_from_sock(struct listener *listener)
                socklen_t len = sizeof(addr);
                uv_os_sock_t fd = accept4(listener->fd, (struct sockaddr *)&addr, &len, SOCK_CLOEXEC | SOCK_NONBLOCK);
                if (fd == -1) {
-                       if (!net_wouldblock())
+                       if (errno != EAGAIN && errno != EWOULDBLOCK)
                                perror("accept4");
                        break;
                }
index 233a02e..4bd3862 100644 (file)
@@ -196,7 +196,7 @@ void recvProc(struct client_data *cl) {
                                        return;
                                // Error
                                case -1:
-                                       if(!net_wouldblock()){
+                                       if (errno != EAGAIN && errno != EWOULDBLOCK) {
                                                perror("recv");
                                                killConnection(cl, 0);
                                        } else {
@@ -255,7 +255,7 @@ static int sendClientRaw(struct client_data *cl, const char *buf, size_t len)
                        if (!rv)
                                return -1;
                        if (rv == -1) {
-                               if (net_wouldblock()) {
+                               if (errno == EAGAIN || errno == EWOULDBLOCK) {
                                        cl->want_write_for_write = 1;
                                        return len;
                                } else {
index 571b2ba..981a9df 100644 (file)
@@ -45,5 +45,4 @@
 #include <netdb.h>
 #include <fcntl.h>
 #include <signal.h>
-#define net_wouldblock() (errno == EAGAIN || errno == EWOULDBLOCK)
 #endif