Handle EWOULDBLOCK at socket communication (#7596)
[libt2n] / 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)