[Libreoffice-commits] online.git: loolwsd/LOOLBroker.cpp loolwsd/LOOLKit.cpp
Ashod Nakashian
ashod.nakashian at collabora.co.uk
Mon Jan 4 17:04:26 PST 2016
loolwsd/LOOLBroker.cpp | 26 ++++++++------------------
loolwsd/LOOLKit.cpp | 19 ++++++-------------
2 files changed, 14 insertions(+), 31 deletions(-)
New commits:
commit 53bff1f1ca5e7a310e74123dc736e1ac8d37f8c2
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
Date: Sun Jan 3 13:25:55 2016 -0500
loolwsd: fused setting the url and loading a document
Change-Id: Ia85fa5e5550c7cc8479e4a368cadc77198a30191
Reviewed-on: https://gerrit.libreoffice.org/21094
Reviewed-by: Ashod Nakashian <ashnakash at gmail.com>
Tested-by: Ashod Nakashian <ashnakash at gmail.com>
diff --git a/loolwsd/LOOLBroker.cpp b/loolwsd/LOOLBroker.cpp
index 31c114b..169e725 100644
--- a/loolwsd/LOOLBroker.cpp
+++ b/loolwsd/LOOLBroker.cpp
@@ -156,8 +156,9 @@ class PipeRunnable: public Runnable
{
public:
PipeRunnable()
+ : _pStart(nullptr),
+ _pEnd(nullptr)
{
- _pStart = _pEnd = nullptr;
}
ssize_t getResponseLine(int nPipeReader, std::string& aLine)
@@ -211,16 +212,10 @@ public:
return nBytes;
}
- ssize_t createThread(Process::PID nPID, const std::string& aTID)
+ ssize_t createThread(Process::PID nPID, const std::string& aTID, const std::string& aURL)
{
std::string aResponse;
- std::string aMessage = "thread " + aTID + "\r\n";
- return sendMessage(_childProcesses[nPID], aMessage);
- }
-
- ssize_t updateURL(Process::PID nPID, const std::string& aURL)
- {
- std::string aMessage = "url " + aURL + "\r\n";
+ std::string aMessage = "thread " + aTID + " " + aURL + "\r\n";
return sendMessage(_childProcesses[nPID], aMessage);
}
@@ -293,7 +288,7 @@ public:
{
Log::debug("Cache found URL [" + aURL + "] hosted on child [" + std::to_string(aIterURL->second) +
"]. Creating view for thread [" + aTID + "].");
- if (createThread(aIterURL->second, aTID) < 0)
+ if (createThread(aIterURL->second, aTID, aURL) < 0)
Log::error("Cache: Error creating thread.");
return;
@@ -308,7 +303,7 @@ public:
{
Log::debug("Search found URL [" + aURL + "] hosted by child [" + std::to_string(nPID) +
"]. Creating view for thread [" + aTID + "].");
- if (createThread(nPID, aTID) < 0)
+ if (createThread(nPID, aTID, aURL) < 0)
Log::error("Search: Error creating thread.");
else
_cacheURL[aURL] = nPID;
@@ -321,13 +316,8 @@ public:
{
const auto aItem = _emptyURL.front();
Log::trace("No child found for URL [" + aURL + "].");
- if (updateURL(aItem, aURL) < 0)
- {
- Log::error("New: Error update URL.");
- return;
- }
- if (createThread(aItem, aTID) < 0)
+ if (createThread(aItem, aTID, aURL) < 0)
{
Log::error("New: Error creating thread.");
return;
@@ -361,7 +351,7 @@ public:
pStart = aBuffer;
pEnd = aBuffer;
- static const std::string thread_name = "broker_pipe_reader";
+ static const std::string thread_name = "brk_pipe_reader";
#ifdef __linux
if (prctl(PR_SET_NAME, reinterpret_cast<unsigned long>(thread_name.c_str()), 0, 0, 0) != 0)
Log::error("Cannot set thread name to " + thread_name + ".");
diff --git a/loolwsd/LOOLKit.cpp b/loolwsd/LOOLKit.cpp
index 142f935..a1917e5 100644
--- a/loolwsd/LOOLKit.cpp
+++ b/loolwsd/LOOLKit.cpp
@@ -640,7 +640,6 @@ void run_lok_main(const std::string &loSubPath, const std::string& childId, cons
char* pStart = nullptr;
char* pEnd = nullptr;
- std::string aURL;
std::map<std::string, std::shared_ptr<Document>> _documents;
assert(!childId.empty());
@@ -760,20 +759,14 @@ void run_lok_main(const std::string &loSubPath, const std::string& childId, cons
else if (tokens[0] == "thread")
{
const std::string& sessionId = tokens[1];
- Log::debug("Thread request for [" + sessionId + "]");
+ const std::string& url = tokens[2];
+ Log::debug("Thread request for session [" + sessionId + "], url: [" + url + "].");
- //FIXME: for now we expect only one document per process.
- assert(_documents.size() == 1);
- assert(_documents[aURL]);
+ auto it = _documents.lower_bound(url);
+ if (it == _documents.end())
+ it = _documents.emplace_hint(it, url, std::make_shared<Document>(loKit.get(), childId, url));
- _documents[aURL]->createSession(sessionId);
- }
- else if (tokens[0] == "url")
- {
- // When multi-documents per-process is supported
- // this will need to move to search or thread.
- aURL = tokens[1];
- _documents.emplace(aURL, std::make_shared<Document>(loKit.get(), childId, aURL));
+ it->second->createSession(sessionId);
}
else
{
More information about the Libreoffice-commits
mailing list