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

Ashod Nakashian ashod.nakashian at collabora.co.uk
Mon Feb 20 04:35:50 UTC 2017


 net/socket.hpp |   30 ++++++++++++++++++------------
 1 file changed, 18 insertions(+), 12 deletions(-)

New commits:
commit e6d971f1f70a85c034fd362b09a9283411fb687a
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
Date:   Sun Feb 19 14:47:05 2017 -0500

    nb: flush all write data as long as we make progress
    
    Change-Id: I138c54258eb54570e7a583bb62b1f4d26ef70ef1
    Reviewed-on: https://gerrit.libreoffice.org/34447
    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 400d940..5f63818 100644
--- a/net/socket.hpp
+++ b/net/socket.hpp
@@ -351,20 +351,26 @@ public:
     /// Override to write data out to socket.
     virtual void writeOutgoingData()
     {
-        assert (_outBuffer.size() > 0);
-        ssize_t len;
-        do
+        while (!_outBuffer.empty())
         {
-            len = writeData(&_outBuffer[0], _outBuffer.size());
-        }
-        while (len < 0 && errno == EINTR);
+            ssize_t len;
+            do
+            {
+                len = writeData(&_outBuffer[0], _outBuffer.size());
+            }
+            while (len < 0 && errno == EINTR);
 
-        if (len > 0)
-        {
-            _outBuffer.erase(_outBuffer.begin(),
-                             _outBuffer.begin() + len);
+            if (len > 0)
+            {
+                _outBuffer.erase(_outBuffer.begin(),
+                                _outBuffer.begin() + len);
+            }
+            else
+            {
+                // Poll will handle errors.
+                break;
+            }
         }
-        // else poll will handle errors
     }
 
     /// Override to handle reading of socket data differently.
@@ -381,7 +387,7 @@ public:
 
     int getPollEvents() override
     {
-        // Only poll for read we if we have nothing to write.
+        // Only poll for read if we have nothing to write.
         return (_outBuffer.empty() ? POLLIN : POLLIN | POLLOUT);
     }
 


More information about the Libreoffice-commits mailing list