[Libreoffice-commits] online.git: loolwsd/test

Ashod Nakashian ashod.nakashian at collabora.co.uk
Sun May 8 04:26:19 UTC 2016


 loolwsd/test/UnitPrefork.cpp |   14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

New commits:
commit 5c47a42fea8c6792ff618611e563c4b5810cf4a7
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
Date:   Sat May 7 16:55:48 2016 -0400

    loolwsd: handle socket errors in Prefork Unit
    
    Change-Id: Idc5a2ea776e0b8f0cde43526d690468e1969e611
    Reviewed-on: https://gerrit.libreoffice.org/24741
    Reviewed-by: Ashod Nakashian <ashnakash at gmail.com>
    Tested-by: Ashod Nakashian <ashnakash at gmail.com>

diff --git a/loolwsd/test/UnitPrefork.cpp b/loolwsd/test/UnitPrefork.cpp
index a9fdbba..58fbccc 100644
--- a/loolwsd/test/UnitPrefork.cpp
+++ b/loolwsd/test/UnitPrefork.cpp
@@ -22,6 +22,7 @@
 
 #include <Poco/Timestamp.h>
 #include <Poco/StringTokenizer.h>
+#include <Poco/Net/WebSocket.h>
 
 const int NumToPrefork = 20;
 
@@ -56,8 +57,6 @@ public:
     {
         /// Fetch memory usage data from the last process ...
         socket->sendFrame("unit-memdump: \n", sizeof("unit-memdump: \n")-1);
-        int flags;
-        char buffer[4096];
 
         static const Poco::Timespan waitTime(COMMAND_TIMEOUT_MS * 1000);
         if (!socket->poll(waitTime, Poco::Net::Socket::SELECT_READ))
@@ -66,9 +65,16 @@ public:
             return;
         }
 
-        int length = IoUtil::receiveFrame(*socket, buffer, sizeof (buffer), flags);
-        std::string memory = LOOLProtocol::getFirstLine(buffer, length);
+        int flags;
+        char buffer[4096];
+        const int length = IoUtil::receiveFrame(*socket, buffer, sizeof (buffer), flags);
+        if (length <= 0 || ((flags & Poco::Net::WebSocket::FRAME_OP_BITMASK) == Poco::Net::WebSocket::FRAME_OP_CLOSE))
+        {
+            _failure = "Failed to read child response to unit-memdump command.";
+            return;
+        }
 
+        const std::string memory = LOOLProtocol::getFirstLine(buffer, length);
         if (!memory.compare(0,6,"Error:"))
             _failure = memory;
         else


More information about the Libreoffice-commits mailing list