wsd/DocumentBroker.cpp |   13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

New commits:
commit 06249045006c438e41ec7037778fcc57017735ec
Author: Ashod Nakashian <[email protected]>
Date:   Mon Mar 27 20:50:30 2017 -0400

    wsd: flush sockets using timed loops
    
    Change-Id: If6cc6194aa36a770913b777a8f19617fea6ba4a7
    Reviewed-on: https://gerrit.libreoffice.org/35786
    Reviewed-by: Ashod Nakashian <[email protected]>
    Tested-by: Ashod Nakashian <[email protected]>

diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp
index 97b81fdd..384e66cf 100644
--- a/wsd/DocumentBroker.cpp
+++ b/wsd/DocumentBroker.cpp
@@ -248,8 +248,17 @@ void DocumentBroker::pollThread()
     }
 
     // Flush socket data.
-    for (int i = 0; i < 7 && _poll->getSocketCount() > 0; ++i)
-        _poll->poll(POLL_TIMEOUT_MS / 5);
+    const int flushTimeoutMs = POLL_TIMEOUT_MS * 2; // ~1000ms
+    const auto flushStartTime = std::chrono::steady_clock::now();
+    while (_poll->getSocketCount())
+    {
+        const auto now = std::chrono::steady_clock::now();
+        const int elapsedMs = 
std::chrono::duration_cast<std::chrono::milliseconds>(now - 
flushStartTime).count();
+        if (elapsedMs > flushTimeoutMs)
+            break;
+
+        _poll->poll(std::min(flushTimeoutMs - elapsedMs, POLL_TIMEOUT_MS / 5));
+    }
 
     // Terminate properly while we can.
     auto lock = getLock();
_______________________________________________
Libreoffice-commits mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to