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

Michael Meeks michael.meeks at collabora.com
Fri Apr 7 20:00:09 UTC 2017


 net/Socket.hpp  |    2 ++
 wsd/LOOLWSD.cpp |    7 ++++---
 2 files changed, 6 insertions(+), 3 deletions(-)

New commits:
commit 254de88a586d3599df16201ff2713ad6f086c200
Author: Michael Meeks <michael.meeks at collabora.com>
Date:   Fri Apr 7 20:47:10 2017 +0100

    Clear ownership of socket while it is being transferred.
    
    This addresses a gap between ServerSocket accepting new sockets,
    and their being added to their new polls.

diff --git a/net/Socket.hpp b/net/Socket.hpp
index 3b44e803..33dbbe5e 100644
--- a/net/Socket.hpp
+++ b/net/Socket.hpp
@@ -453,6 +453,8 @@ public:
         {
             std::lock_guard<std::mutex> lock(_mutex);
             LOG_DBG("Inserting socket #" << newSocket->getFD() << " into " << _name);
+            // sockets in transit are un-owned.
+            newSocket->setThreadOwner(std::thread::id(0));
             _newSockets.emplace_back(newSocket);
             wakeup();
         }
diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index 0fe28328..1fca253b 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -1445,12 +1445,13 @@ private:
             UnitWSD::get().newChild(*this);
 
             auto child = std::make_shared<ChildProcess>(pid, socket, request);
-            _childProcess = child; // weak
-            addNewChild(child);
 
-            // We no longer own this socket.
+            // Drop pretentions of ownership before adding to the list.
             socket->setThreadOwner(std::thread::id(0));
 
+            _childProcess = child; // weak
+            addNewChild(child);
+
             // Remove from prisoner poll since there is no activity
             // until we attach the childProcess (with this socket)
             // to a docBroker, which will do the polling.


More information about the Libreoffice-commits mailing list