[Libreoffice-commits] online.git: wsd/LOOLWSD.cpp

Ashod Nakashian ashod.nakashian at collabora.co.uk
Tue Jan 3 06:01:28 UTC 2017


 wsd/LOOLWSD.cpp |   37 ++++++++++++++++++++-----------------
 1 file changed, 20 insertions(+), 17 deletions(-)

New commits:
commit 9c35ab156a62cdd5728649e9363beb80354f6822
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
Date:   Tue Jan 3 00:24:39 2017 -0500

    wsd: exception-safe socket closing
    
    Change-Id: Id51e61195439e100758d63e5e3417e23b0f0fc53
    Reviewed-on: https://gerrit.libreoffice.org/32678
    Reviewed-by: Ashod Nakashian <ashnakash at gmail.com>
    Tested-by: Ashod Nakashian <ashnakash at gmail.com>

diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index 7b621e5..4798eaf 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -1100,13 +1100,6 @@ private:
                 }
             }
 
-            if (SigUtil::isShuttingDown())
-            {
-                std::lock_guard<std::mutex> lock(ClientWebSocketsMutex);
-                LOG_TRC("Capturing Client WS for [" << id << "]");
-                ClientWebSockets.push_back(ws);
-            }
-
             LOOLWSD::dumpEventTrace(docBroker->getJailId(), id, "EndSession: " + uri);
             LOG_INF("Finishing GET request handler for session [" << id << "].");
         }
@@ -1126,23 +1119,33 @@ private:
             LOG_ERR("Error in client request handler: " << exc.what());
         }
 
-        if (session->isCloseFrame())
-        {
-            LOG_TRC("Normal close handshake.");
-            // Client initiated close handshake
-            // respond close frame
-            ws->shutdown();
-        }
-        else
+        try
         {
-            if (!SigUtil::isShuttingDown())
+            if (session->isCloseFrame())
+            {
+                LOG_TRC("Normal close handshake.");
+                // Client initiated close handshake
+                // respond close frame
+                ws->shutdown();
+            }
+            else if (!SigUtil::isShuttingDown())
             {
                 // something wrong, with internal exceptions
                 LOG_TRC("Abnormal close handshake.");
                 session->closeFrame();
-                // FIXME: handle exception thrown from here ? ...
                 ws->shutdown(WebSocket::WS_ENDPOINT_GOING_AWAY);
             }
+            else
+            {
+                std::lock_guard<std::mutex> lock(ClientWebSocketsMutex);
+                LOG_TRC("Capturing Client WS for [" << id << "]");
+                ClientWebSockets.push_back(ws);
+            }
+        }
+        catch (const std::exception& exc)
+        {
+            LOG_WRN("Exception while closing socket for session [" << id <<
+                    "] of docKey [" << docKey << "]: " << exc.what());
         }
     }
 


More information about the Libreoffice-commits mailing list