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

Tor Lillqvist tml at collabora.com
Thu Feb 25 14:46:30 UTC 2016


 loolwsd/LOOLKit.cpp         |    7 ++++++-
 loolwsd/test/httpwstest.cpp |   20 ++++++++++++++------
 2 files changed, 20 insertions(+), 7 deletions(-)

New commits:
commit ab3169ecdcbe65284b08e2becd2ce0079a36fbd2
Author: Tor Lillqvist <tml at collabora.com>
Date:   Thu Feb 25 16:43:46 2016 +0200

    Add some more Log::info() calls
    
    We want to be able to see exactly when document loading and password
    management is done and how long it takes.

diff --git a/loolwsd/LOOLKit.cpp b/loolwsd/LOOLKit.cpp
index 94559aa..3aaec05 100644
--- a/loolwsd/LOOLKit.cpp
+++ b/loolwsd/LOOLKit.cpp
@@ -479,6 +479,8 @@ public:
     /// Set Document password for given URL
     void setDocumentPassword(int nPasswordType)
     {
+        Log::info("setDocumentPassword: passwordProtected=" + std::to_string(_isDocPasswordProtected) + " passwordProvided=" + std::to_string(_isDocPasswordProvided) + " password='" + _docPassword + "'");
+
         if (_isDocPasswordProtected && _isDocPasswordProvided)
         {
             // it means this is the second attempt with the wrong password; abort the load operation
@@ -493,10 +495,12 @@ public:
         else if (nPasswordType == LOK_CALLBACK_DOCUMENT_PASSWORD_TO_MODIFY)
             _docPasswordType = PasswordType::ToModify;
 
+        Log::info("Caling _loKit->pClass->setDocumentPassword");
         if (_isDocPasswordProvided)
             _loKit->pClass->setDocumentPassword(_loKit, _jailedUrl.c_str(), _docPassword.c_str());
         else
             _loKit->pClass->setDocumentPassword(_loKit, _jailedUrl.c_str(), nullptr);
+        Log::info("setDocumentPassword returned");
     }
 
 
@@ -628,6 +632,7 @@ private:
             _docPassword = docPassword;
             _jailedUrl = uri;
             _isDocPasswordProtected = false;
+            Log::info("Calling _loKit->pClass->documentLoad");
             if ((_loKitDocument = _loKit->pClass->documentLoad(_loKit, uri.c_str())) == nullptr)
             {
                 Log::error("Failed to load: " + uri + ", error: " + _loKit->pClass->getError(_loKit));
@@ -650,7 +655,7 @@ private:
 
                 return nullptr;
             }
-
+            Log::info("documentLoad() returned");
             // Retake the lock.
             lock.lock();
 
commit 3cad8c183a3a470949670db4cc8f3de1c9c39103
Author: Tor Lillqvist <tml at collabora.com>
Date:   Thu Feb 25 15:58:13 2016 +0200

    Seems that 10 seconds is not enough
    
    One has to love arbitrary retry counts and timeouts. Loading the
    password-protected.ods in a loolkit process, with correct password
    provided, takes 12 seconds on my machine. I think this slowness is
    because the NSS code LO uses to do crypto wants to initialize its
    crypto goodness in various ways that don't work so well inside a
    chroot jail. Presumably it uses some wait with timeout when attempting
    to do something which doesn't succeed. For instance it tries to run
    netstat -in. (In an interactive LibreOffice the doc loads fairly
    instantly.) Oh well.

diff --git a/loolwsd/test/httpwstest.cpp b/loolwsd/test/httpwstest.cpp
index 4b8b91c..d585db3 100644
--- a/loolwsd/test/httpwstest.cpp
+++ b/loolwsd/test/httpwstest.cpp
@@ -428,7 +428,7 @@ bool HTTPWSTest::isDocumentLoaded(Poco::Net::WebSocket& ws)
     {
         int flags;
         int bytes;
-        int retries = 10;
+        int retries = 30;
         const Poco::Timespan waitTime(1000000);
 
         ws.setReceiveTimeout(0);
commit ff7a0ac8eecabed3de8cdf0730ad6c64769cf8f1
Author: Tor Lillqvist <tml at collabora.com>
Date:   Thu Feb 25 15:57:52 2016 +0200

    Add more verbose debug output...
    
    Debugging this crack is really hard.

diff --git a/loolwsd/test/httpwstest.cpp b/loolwsd/test/httpwstest.cpp
index 15604ba..4b8b91c 100644
--- a/loolwsd/test/httpwstest.cpp
+++ b/loolwsd/test/httpwstest.cpp
@@ -108,9 +108,10 @@ void HTTPWSTest::testPaste()
         {
             char buffer[READ_BUFFER_SIZE];
             n = socket.receiveFrame(buffer, sizeof(buffer), flags);
+            std::cout << "Got " << n << " bytes, flags: " << std::hex << flags << std::dec << '\n';
             if (n > 0 && (flags & Poco::Net::WebSocket::FRAME_OP_BITMASK) != Poco::Net::WebSocket::FRAME_OP_CLOSE)
             {
-                std::cout << "Received message length " << n << ": " << LOOLProtocol::getAbbreviatedMessage(buffer, n) << '\n';
+                std::cout << "Received message: " << LOOLProtocol::getAbbreviatedMessage(buffer, n) << '\n';
                 const std::string line = LOOLProtocol::getFirstLine(buffer, n);
                 const std::string prefix = "textselectioncontent: ";
                 if (line.find(prefix) == 0)
@@ -200,9 +201,10 @@ void HTTPWSTest::testRenderingOptions()
         {
             char buffer[READ_BUFFER_SIZE];
             n = socket.receiveFrame(buffer, sizeof(buffer), flags);
+            std::cout << "Got " << n << " bytes, flags: " << std::hex << flags << std::dec << '\n';
             if (n > 0 && (flags & Poco::Net::WebSocket::FRAME_OP_BITMASK) != Poco::Net::WebSocket::FRAME_OP_CLOSE)
             {
-                std::cout << "Received message length " << n << ": " << LOOLProtocol::getAbbreviatedMessage(buffer, n) << '\n';
+                std::cout << "Received message: " << LOOLProtocol::getAbbreviatedMessage(buffer, n) << '\n';
                 std::string line = LOOLProtocol::getFirstLine(buffer, n);
                 std::string prefix = "status: ";
                 if (line.find(prefix) == 0)
@@ -430,6 +432,7 @@ bool HTTPWSTest::isDocumentLoaded(Poco::Net::WebSocket& ws)
         const Poco::Timespan waitTime(1000000);
 
         ws.setReceiveTimeout(0);
+        std::cout << "==> isDocumentLoaded\n";
         do
         {
             char buffer[READ_BUFFER_SIZE];
@@ -437,9 +440,10 @@ bool HTTPWSTest::isDocumentLoaded(Poco::Net::WebSocket& ws)
             if (ws.poll(waitTime, Poco::Net::Socket::SELECT_READ))
             {
                 bytes = ws.receiveFrame(buffer, sizeof(buffer), flags);
+                std::cout << "Got " << bytes << " bytes, flags: " << std::hex << flags << std::dec << '\n';
                 if (bytes > 0 && (flags & Poco::Net::WebSocket::FRAME_OP_BITMASK) != Poco::Net::WebSocket::FRAME_OP_CLOSE)
                 {
-                    std::cout << "Received message length " << bytes << ": " << LOOLProtocol::getAbbreviatedMessage(buffer, bytes) << '\n';
+                    std::cout << "Received message: " << LOOLProtocol::getAbbreviatedMessage(buffer, bytes) << '\n';
                     const std::string line = LOOLProtocol::getFirstLine(buffer, bytes);
                     const std::string prefixIndicator = "statusindicatorfinish:";
                     const std::string prefixStatus = "status:";
@@ -453,6 +457,7 @@ bool HTTPWSTest::isDocumentLoaded(Poco::Net::WebSocket& ws)
             }
             else
             {
+                std::cout << "Timeout\n";
                 --retries;
             }
         }
@@ -472,11 +477,12 @@ void HTTPWSTest::getResponseMessage(Poco::Net::WebSocket& ws, const std::string&
     {
         int flags;
         int bytes;
-        int retries = 10;
+        int retries = 20;
         const Poco::Timespan waitTime(1000000);
 
         response.clear();
         ws.setReceiveTimeout(0);
+        std::cout << "==> getResponseMessage(" << prefix << ")\n";
         do
         {
             char buffer[READ_BUFFER_SIZE];
@@ -484,9 +490,10 @@ void HTTPWSTest::getResponseMessage(Poco::Net::WebSocket& ws, const std::string&
             if (ws.poll(waitTime, Poco::Net::Socket::SELECT_READ))
             {
                 bytes = ws.receiveFrame(buffer, sizeof(buffer), flags);
+                std::cout << "Got " << bytes << " bytes, flags: " << std::hex << flags << std::dec << '\n';
                 if (bytes > 0 && (flags & Poco::Net::WebSocket::FRAME_OP_BITMASK) != Poco::Net::WebSocket::FRAME_OP_CLOSE)
                 {
-                    std::cout << "Received message length " << bytes << ": " << LOOLProtocol::getAbbreviatedMessage(buffer, bytes) << '\n';
+                    std::cout << "Received message: " << LOOLProtocol::getAbbreviatedMessage(buffer, bytes) << '\n';
                     const std::string message = isLine ?
                                                 LOOLProtocol::getFirstLine(buffer, bytes) :
                                                 std::string(buffer, bytes);
@@ -501,6 +508,7 @@ void HTTPWSTest::getResponseMessage(Poco::Net::WebSocket& ws, const std::string&
             }
             else
             {
+                std::cout << "Timeout\n";
                 --retries;
             }
         }


More information about the Libreoffice-commits mailing list