[Libreoffice-commits] online.git: loolwsd/LOOLSession.cpp loolwsd/MasterProcessSession.cpp

Ashod Nakashian ashod.nakashian at collabora.co.uk
Mon Jan 11 20:35:34 PST 2016


 loolwsd/LOOLSession.cpp          |    3 ++-
 loolwsd/MasterProcessSession.cpp |   23 ++++++++++++++++-------
 2 files changed, 18 insertions(+), 8 deletions(-)

New commits:
commit 6668dca7aca1ce6dd2ac76eeb020318797aeee7b
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
Date:   Mon Jan 11 23:22:02 2016 -0500

    loolwsd: handle I/O error while destroying MasterProcessSession
    
    Change-Id: I9618fb57bcb3cdb472d03abb6c49d649afbf25a5
    Reviewed-on: https://gerrit.libreoffice.org/21379
    Reviewed-by: Ashod Nakashian <ashnakash at gmail.com>
    Tested-by: Ashod Nakashian <ashnakash at gmail.com>

diff --git a/loolwsd/LOOLSession.cpp b/loolwsd/LOOLSession.cpp
index a730937..0941bf5 100644
--- a/loolwsd/LOOLSession.cpp
+++ b/loolwsd/LOOLSession.cpp
@@ -185,7 +185,8 @@ bool LOOLSession::handleInput(const char *buffer, int length)
     }
     catch (const Exception& exc)
     {
-        Log::error() << "Error while handling [" + getFirstLine(buffer, length) + "]. "
+        Log::error() << "Error while handling [" + getFirstLine(buffer, length) + "] in "
+                     << getName() << ". "
                      << exc.displayText()
                      << (exc.nested() ? " (" + exc.nested()->displayText() + ")" : "")
                      << Log::end;
diff --git a/loolwsd/MasterProcessSession.cpp b/loolwsd/MasterProcessSession.cpp
index abe0809..2440e71 100644
--- a/loolwsd/MasterProcessSession.cpp
+++ b/loolwsd/MasterProcessSession.cpp
@@ -51,16 +51,25 @@ MasterProcessSession::~MasterProcessSession()
 {
     Log::info("~MasterProcessSession dtor [" + getName() + "].");
 
-    auto peer = _peer.lock();
-    if (_kind == Kind::ToClient && peer)
+    try
     {
-        peer->sendTextFrame("eof");
+        // We could be unwinding because our peer's connection
+        // died. Handle I/O errors in that case.
+        auto peer = _peer.lock();
+        if (_kind == Kind::ToClient && peer)
+        {
+            peer->sendTextFrame("eof");
+        }
+        else
+        if (_kind == Kind::ToPrisoner && peer)
+        {
+            peer->_bShutdown = true;
+            Util::shutdownWebSocket(*(peer->_ws));
+        }
     }
-    else
-    if (_kind == Kind::ToPrisoner && peer)
+    catch (const std::exception& exc)
     {
-        peer->_bShutdown = true;
-        Util::shutdownWebSocket(*(peer->_ws));
+        Log::error(std::string("Exception: ") + exc.what());
     }
 }
 


More information about the Libreoffice-commits mailing list