[Libreoffice-commits] online.git: common/Session.hpp net/WebSocketHandler.hpp wsd/ClientSession.cpp wsd/DocumentBroker.cpp

Michael Meeks (via logerrit) logerrit at kemper.freedesktop.org
Thu Mar 5 19:23:05 UTC 2020


 common/Session.hpp       |   13 +++++++++++--
 net/WebSocketHandler.hpp |    3 ++-
 wsd/ClientSession.cpp    |    6 +++---
 wsd/DocumentBroker.cpp   |    2 +-
 4 files changed, 17 insertions(+), 7 deletions(-)

New commits:
commit 17cbb2b7b9d79961660f7ba929dd89db2cafea80
Author:     Michael Meeks <michael.meeks at collabora.com>
AuthorDate: Thu Mar 5 18:42:00 2020 +0000
Commit:     Michael Meeks <michael.meeks at collabora.com>
CommitDate: Thu Mar 5 20:22:32 2020 +0100

    Session: simplify shutdown and privatize some pieces.
    
    Change-Id: Ifbb40f6a88590bd87dbfada73fa26eb0b61705fb
    Reviewed-on: https://gerrit.libreoffice.org/c/online/+/90058
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
    Reviewed-by: Michael Meeks <michael.meeks at collabora.com>

diff --git a/common/Session.hpp b/common/Session.hpp
index 8171fef64..093234a2d 100644
--- a/common/Session.hpp
+++ b/common/Session.hpp
@@ -100,8 +100,13 @@ public:
     /// Called to handle disconnection command from socket.
     virtual bool handleDisconnect();
 
-    void shutdown(const WebSocketHandler::StatusCodes statusCode = WebSocketHandler::StatusCodes::NORMAL_CLOSE,
-                  const std::string& statusMessage = "");
+    /// clean & normal shutdown
+    void shutdownNormal(const std::string& statusMessage = "")
+        { shutdown(WebSocketHandler::StatusCodes::NORMAL_CLOSE, statusMessage); }
+
+    /// abnormal / hash shutdown end-point going away
+    void shutdownGoingAway(const std::string& statusMessage = "")
+        { shutdown(WebSocketHandler::StatusCodes::ENDPOINT_GOING_AWAY, statusMessage); }
 
     bool isActive() const { return _isActive; }
     void setIsActive(bool active) { _isActive = active; }
@@ -178,6 +183,10 @@ protected:
     void dumpState(std::ostream& os) override;
 
 private:
+
+    void shutdown(const WebSocketHandler::StatusCodes statusCode = WebSocketHandler::StatusCodes::NORMAL_CLOSE,
+                  const std::string& statusMessage = "");
+
     virtual bool _handleInput(const char* buffer, int length) = 0;
 
     /// A session ID specific to an end-to-end connection (from user to lokit).
diff --git a/net/WebSocketHandler.hpp b/net/WebSocketHandler.hpp
index 17d364d3a..f18927a22 100644
--- a/net/WebSocketHandler.hpp
+++ b/net/WebSocketHandler.hpp
@@ -437,6 +437,7 @@ public:
     }
 
 #if !MOBILEAPP
+private:
     /// Send a ping message
     void sendPingOrPong(std::chrono::steady_clock::time_point now,
                         const char* data, const size_t len,
@@ -493,7 +494,7 @@ public:
         }
 #endif
     }
-
+public:
     /// By default rely on the socket buffer.
     void performWrites() override {}
 
diff --git a/wsd/ClientSession.cpp b/wsd/ClientSession.cpp
index 8a79d46bb..5639448e7 100644
--- a/wsd/ClientSession.cpp
+++ b/wsd/ClientSession.cpp
@@ -1675,20 +1675,20 @@ void ClientSession::onDisconnect()
             LOG_TRC("Normal close handshake.");
             // Client initiated close handshake
             // respond with close frame
-            shutdown();
+            shutdownNormal();
         }
         else if (!SigUtil::getShutdownRequestFlag())
         {
             // something wrong, with internal exceptions
             LOG_TRC("Abnormal close handshake.");
             closeFrame();
-            shutdown(WebSocketHandler::StatusCodes::ENDPOINT_GOING_AWAY);
+            shutdownGoingAway();
         }
         else
         {
             LOG_TRC("Server recycling.");
             closeFrame();
-            shutdown(WebSocketHandler::StatusCodes::ENDPOINT_GOING_AWAY);
+            shutdownGoingAway();
         }
     }
     catch (const std::exception& exc)
diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp
index 18bcdce63..b89fc8439 100644
--- a/wsd/DocumentBroker.cpp
+++ b/wsd/DocumentBroker.cpp
@@ -2135,7 +2135,7 @@ void DocumentBroker::shutdownClients(const std::string& closeReason)
             else
             {
                 // Notify the client and disconnect.
-                session->shutdown(WebSocketHandler::StatusCodes::ENDPOINT_GOING_AWAY, closeReason);
+                session->shutdownGoingAway(closeReason);
 
                 // Remove session, save, and mark to destroy.
                 removeSession(session->getId());


More information about the Libreoffice-commits mailing list