[Libreoffice-commits] online.git: Branch 'private/Ashod/nonblocking' - net/socket.hpp

Ashod Nakashian ashod.nakashian at collabora.co.uk
Fri Feb 17 06:45:57 UTC 2017


 net/socket.hpp |   11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

New commits:
commit d835d625187554e96436e3de83245bd673db86b9
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
Date:   Thu Feb 16 21:29:18 2017 -0500

    nb: retry on EINTR
    
    Change-Id: Iea972096854308a80f96af056639417be7573a82
    Reviewed-on: https://gerrit.libreoffice.org/34350
    Reviewed-by: Ashod Nakashian <ashnakash at gmail.com>
    Tested-by: Ashod Nakashian <ashnakash at gmail.com>

diff --git a/net/socket.hpp b/net/socket.hpp
index f41befc..2e23c7c 100644
--- a/net/socket.hpp
+++ b/net/socket.hpp
@@ -197,7 +197,7 @@ public:
 
             // Clear the data.
             int dump;
-            if (::read(_wakeup[0], &dump, sizeof(dump)) == -1)
+            while (::read(_wakeup[0], &dump, sizeof(dump)) == -1 && errno == EINTR)
             {
                 // Nothing to do.
             }
@@ -213,9 +213,16 @@ public:
         _newSockets.emplace_back(newSocket);
 
         // wakeup the main-loop.
-        if (::write(_wakeup[1], "w", 1) == -1)
+        int rc;
+        do
         {
             // wakeup pipe is already full.
+            rc = ::write(_wakeup[1], "w", 1);
+        }
+        while (rc == -1 && errno == EINTR);
+
+        if (rc == -1)
+        {
             assert(errno == EAGAIN || errno == EWOULDBLOCK);
         }
     }


More information about the Libreoffice-commits mailing list