wsd: start DocBroker thread before adding callbacks

And move more into the callback to ensure
thread affinity.

Change-Id: I1d6985716d0d36aa488b65263ecb41f444f77255
Reviewed-on: https://gerrit.libreoffice.org/36115
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
This commit is contained in:
Ashod Nakashian 2017-04-05 00:25:15 -04:00 committed by Ashod Nakashian
parent 2576f9c4e9
commit 38f955b5c5

View file

@ -1856,15 +1856,19 @@ private:
auto clientSession = createNewClientSession(nullptr, _id, uriPublic, docBroker, isReadOnly);
if (clientSession)
{
clientSession->setSaveAsSocket(socket);
// Transfer the client socket to the DocumentBroker.
// Move the socket into DocBroker.
docBroker->addSocketToPoll(socket);
socketOwnership = SocketHandlerInterface::SocketOwnership::MOVED;
docBroker->addCallback([&, clientSession]()
// Make sure the thread is running before adding callback.
docBroker->startThread();
docBroker->addCallback([docBroker, socket, clientSession, format]()
{
clientSession->setSaveAsSocket(socket);
// Move the socket into DocBroker.
docBroker->addSocketToPoll(socket);
// First add and load the session.
docBroker->addSession(clientSession);
@ -1888,8 +1892,6 @@ private:
clientSession->handleMessage(true, WebSocketHandler::WSOpCode::Text, saveasRequest);
});
docBroker->startThread();
sent = true;
}
else
@ -2083,6 +2085,9 @@ private:
// Remove from current poll as we're moving ownership.
socketOwnership = SocketHandlerInterface::SocketOwnership::MOVED;
// Make sure the thread is running before adding callback.
docBroker->startThread();
docBroker->addCallback([docBroker, socket, clientSession]()
{
// Set the ClientSession to handle Socket events.
@ -2095,8 +2100,6 @@ private:
// Add and load the session.
docBroker->addSession(clientSession);
});
docBroker->startThread();
}
else
{