Handle EWOULDBLOCK at socket communication (#7596)
authorGabriel Braga <gabriel.braga@intra2net.com>
Thu, 4 Apr 2024 07:48:57 +0000 (09:48 +0200)
committerThomas Jarosch <thomas.jarosch@intra2net.com>
Fri, 5 Apr 2024 07:17:34 +0000 (09:17 +0200)
This adds treatment to the EWOULDBLOCK error on socket comms.
Previously only EAGAIN was treated.

src/socket_handler.cpp

index 0cc5036..f1f5ef7 100644 (file)
@@ -248,7 +248,7 @@ bool socket_handler::fill_buffer(std::string& buffer)
 
         if (nbytes < 0)
         {
-            if (errno == EAGAIN)
+            if (errno == EAGAIN || errno == EWOULDBLOCK)
                 return read_something;                // no (more) data was waiting
             else if (errno == EINTR)
             {
@@ -301,10 +301,10 @@ void socket_handler::socket_write(const std::string& data)
 
         int rtn;
         while ((rtn=::write(sock, data.data()+offset, write_size)) == -1 &&
-               (errno == EAGAIN || errno == EINTR))
+               (errno == EAGAIN || errno == EWOULDBLOCK || errno == EINTR))
         {
             wait_ready_to_write(sock,write_timeout);
-            LOGSTREAM(debug,"resuming write() call after EAGAIN or EINTR");
+            LOGSTREAM(debug,"resuming write() call after EAGAIN or EINTR or EWOULDBLOCK");
         }
 
         if (rtn == -1)