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

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Wed Oct 24 07:36:33 UTC 2018


 common/Session.cpp       |    2 +-
 net/WebSocketHandler.hpp |   13 ++++++++++++-
 wsd/ClientSession.cpp    |    2 +-
 wsd/LOOLWSD.cpp          |    8 ++++----
 4 files changed, 18 insertions(+), 7 deletions(-)

New commits:
commit 22fac18fcd17c1cf927da50690cd188b01a245e2
Author:     Miklos Vajna <vmiklos at collabora.co.uk>
AuthorDate: Wed Oct 24 09:35:46 2018 +0200
Commit:     Miklos Vajna <vmiklos at collabora.co.uk>
CommitDate: Wed Oct 24 09:36:13 2018 +0200

    WebSocket: make members private
    
    All of them were protected, but only _socket was used actually. Add a
    protected setter/getter for that field.

diff --git a/common/Session.cpp b/common/Session.cpp
index 34c608924..1c37e5ba2 100644
--- a/common/Session.cpp
+++ b/common/Session.cpp
@@ -234,7 +234,7 @@ void Session::handleMessage(bool /*fin*/, WSOpCode /*code*/, std::vector<char> &
 
 void Session::getIOStats(uint64_t &sent, uint64_t &recv)
 {
-    std::shared_ptr<StreamSocket> socket = _socket.lock();
+    std::shared_ptr<StreamSocket> socket = getSocket().lock();
     if (socket)
         socket->getIOStats(sent, recv);
     else
diff --git a/net/WebSocketHandler.hpp b/net/WebSocketHandler.hpp
index f9abbae42..fcb9d3660 100644
--- a/net/WebSocketHandler.hpp
+++ b/net/WebSocketHandler.hpp
@@ -26,7 +26,7 @@
 
 class WebSocketHandler : public SocketHandlerInterface
 {
-protected:
+private:
     /// The socket that owns us (we can't own it).
     std::weak_ptr<StreamSocket> _socket;
 
@@ -38,6 +38,7 @@ protected:
     bool _isClient;
     bool _isMasking;
 
+protected:
     struct WSFrameMask
     {
         static const unsigned char Fin = 0x80;
@@ -517,6 +518,16 @@ protected:
     {
     }
 
+    std::weak_ptr<StreamSocket>& getSocket()
+    {
+        return _socket;
+    }
+
+    void setSocket(const std::weak_ptr<StreamSocket>& socket)
+    {
+        _socket = socket;
+    }
+
     void dumpState(std::ostream& os) override;
 
 private:
diff --git a/wsd/ClientSession.cpp b/wsd/ClientSession.cpp
index a764a951e..762b5a907 100644
--- a/wsd/ClientSession.cpp
+++ b/wsd/ClientSession.cpp
@@ -1206,7 +1206,7 @@ void ClientSession::dumpState(std::ostream& os)
        << "\n\t\tisAttached: " << _isAttached
        << "\n\t\tkeyEvents: " << _keyEvents;
 
-    std::shared_ptr<StreamSocket> socket = _socket.lock();
+    std::shared_ptr<StreamSocket> socket = getSocket().lock();
     if (socket)
     {
         uint64_t sent, recv;
diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index c2d47ebb1..95d362547 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -1743,13 +1743,13 @@ private:
     /// Keep our socket around ...
     void onConnect(const std::shared_ptr<StreamSocket>& socket) override
     {
-        _socket = socket;
+        setSocket(socket);
         LOG_TRC("#" << socket->getFD() << " Prisoner connected.");
     }
 
     void onDisconnect() override
     {
-        std::shared_ptr<StreamSocket> socket = _socket.lock();
+        std::shared_ptr<StreamSocket> socket = getSocket().lock();
         if (socket)
             LOG_TRC("#" << socket->getFD() << " Prisoner connection disconnected.");
         else
@@ -1782,7 +1782,7 @@ private:
             return;
         }
 
-        std::shared_ptr<StreamSocket> socket = _socket.lock();
+        std::shared_ptr<StreamSocket> socket = getSocket().lock();
 
         Poco::MemoryInputStream message(&socket->_inBuffer[0],
                                         socket->_inBuffer.size());;
@@ -1873,7 +1873,7 @@ private:
             return;
 
         const std::string abbr = getAbbreviatedMessage(data);
-        std::shared_ptr<StreamSocket> socket = _socket.lock();
+        std::shared_ptr<StreamSocket> socket = getSocket().lock();
         if (socket)
             LOG_TRC("#" << socket->getFD() << " Prisoner message [" << abbr << "].");
         else


More information about the Libreoffice-commits mailing list