[Libreoffice-commits] online.git: Branch 'distro/collabora/collabora-online-2-1' - wsd/LOOLWSD.cpp wsd/LOOLWSD.hpp

2017-11-14 Thread Tor Lillqvist
 wsd/LOOLWSD.cpp |   30 ++
 wsd/LOOLWSD.hpp |4 
 2 files changed, 34 insertions(+)

New commits:
commit 18af0a60872e73633674db4ce07d75a5aa1ebc7a
Author: Tor Lillqvist 
Date:   Tue Nov 7 15:12:18 2017 +0200

Add a "plug-in" mechanism

Look in the directory LOOLWSD_CONFIGDIR/conf.d (or pathname passed
with --config-dir option) for extra .xml files containing a Poco
configuration tree. These are not merged with the actual configuration
but kept separate. This commit does not yet actually use them for
anything.

Change-Id: I67ff27e694d6be74a52e7bd027263b00486f60bd
Reviewed-on: https://gerrit.libreoffice.org/44717
Reviewed-by: Aron Budea 
Tested-by: Aron Budea 

diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index 7aed341b..37b83a29 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -48,6 +48,7 @@
 #include 
 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -78,12 +79,14 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
+#include 
 
 #include "Admin.hpp"
 #include "Auth.hpp"
@@ -121,6 +124,7 @@
 
 using namespace LOOLProtocol;
 
+using Poco::DirectoryIterator;
 using Poco::Environment;
 using Poco::Exception;
 using Poco::File;
@@ -153,6 +157,7 @@ using Poco::Util::MissingOptionException;
 using Poco::Util::Option;
 using Poco::Util::OptionSet;
 using Poco::Util::ServerApplication;
+using Poco::Util::XMLConfiguration;
 using Poco::XML::AutoPtr;
 using Poco::XML::DOMParser;
 using Poco::XML::DOMWriter;
@@ -551,12 +556,14 @@ std::string LOOLWSD::ServerName;
 std::string LOOLWSD::FileServerRoot;
 std::string LOOLWSD::LOKitVersion;
 std::string LOOLWSD::ConfigFile = LOOLWSD_CONFIGDIR "/loolwsd.xml";
+std::string LOOLWSD::ConfigDir = LOOLWSD_CONFIGDIR "/conf.d";
 Util::RuntimeConstant LOOLWSD::SSLEnabled;
 Util::RuntimeConstant LOOLWSD::SSLTermination;
 std::set LOOLWSD::EditFileExtensions;
 unsigned LOOLWSD::MaxConnections;
 unsigned LOOLWSD::MaxDocuments;
 std::string LOOLWSD::OverrideWatermark;
+std::set 
LOOLWSD::PluginConfigurations;
 
 static std::string UnitTestLibrary;
 
@@ -681,6 +688,22 @@ void LOOLWSD::initialize(Application& self)
 loadConfiguration(ConfigFile, PRIO_DEFAULT);
 }
 
+// Load extra ("plug-in") configuration files, if present
+File dir(ConfigDir);
+if (dir.exists() && dir.isDirectory())
+{
+for (auto configFileIterator = DirectoryIterator(dir); 
configFileIterator != DirectoryIterator(); ++configFileIterator)
+{
+// Only accept configuration files ending in .xml
+const std::string configFile = 
configFileIterator.path().getFileName();
+if (configFile.length() > 4 && 
strcasecmp(configFile.substr(configFile.length() - 4).data(), ".xml") == 0)
+{
+const std::string fullFileName = dir.path() + "/" + configFile;
+PluginConfigurations.insert(new 
XMLConfiguration(fullFileName));
+}
+}
+}
+
 // Override any settings passed on the command-line.
 AutoPtr overrideConfig(new AppConfigMap(_overrideSettings));
 conf.addWriteable(overrideConfig, PRIO_APPLICATION); // Highest priority
@@ -991,6 +1014,11 @@ void LOOLWSD::defineOptions(OptionSet& optionSet)
 .repeatable(false)
 .argument("path"));
 
+optionSet.addOption(Option("config-dir", "", "Override extra configuration 
directory path.")
+.required(false)
+.repeatable(false)
+.argument("path"));
+
 #if ENABLE_DEBUG
 optionSet.addOption(Option("unitlib", "", "Unit testing library path.")
 .required(false)
@@ -1043,6 +1071,8 @@ void LOOLWSD::handleOption(const std::string& optionName,
 }
 else if (optionName == "config-file")
 ConfigFile = value;
+else if (optionName == "config-dir")
+ConfigDir = value;
 #if ENABLE_DEBUG
 else if (optionName == "unitlib")
 UnitTestLibrary = value;
diff --git a/wsd/LOOLWSD.hpp b/wsd/LOOLWSD.hpp
index 80d2d9e2..ad858a4e 100644
--- a/wsd/LOOLWSD.hpp
+++ b/wsd/LOOLWSD.hpp
@@ -12,10 +12,12 @@
 
 #include 
 #include 
+#include 
 #include 
 
 #include 
 #include 
+#include 
 #include 
 #include 
 
@@ -46,6 +48,7 @@ public:
 static std::string FuzzFileName;
 static std::string Cache;
 static std::string ConfigFile;
+static std::string ConfigDir;
 static std::string SysTemplate;
 static std::string LoTemplate;
 static std::string ChildRoot;
@@ -59,6 +62,7 @@ public:
 static unsigned MaxConnections;
 static unsigned MaxDocuments;
 static std::string OverrideWatermark;
+static std::set 
PluginConfigurations;
 
 /// Flag to shutdown the server.
 std::atomic ShutdownFlag;

[Libreoffice-commits] online.git: Branch 'distro/collabora/collabora-online-2-1' - wsd/LOOLWSD.cpp

2017-11-08 Thread Aron Budea
 wsd/LOOLWSD.cpp |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit 8a3fd8e3548543675223c0463b5cb9fb5804fe43
Author: Aron Budea 
Date:   Wed Nov 8 17:39:18 2017 +0100

wsd: increase preinit timeout 5-fold

Change-Id: I08ab74498ef9396edba5311a7e31b75c5932bbd6
Reviewed-on: https://gerrit.libreoffice.org/44496
Reviewed-by: Jan Holesovsky 
Tested-by: Jan Holesovsky 

diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index b3aaab7e..7aed341b 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -2613,7 +2613,7 @@ int LOOLWSD::innerMain()
 {
 std::unique_lock lock(NewChildrenMutex);
 
-const auto timeoutMs = CHILD_TIMEOUT_MS * (LOOLWSD::NoCapsForKit ? 150 
: 10);
+const auto timeoutMs = 5 * CHILD_TIMEOUT_MS * (LOOLWSD::NoCapsForKit ? 
150 : 10);
 const auto timeout = std::chrono::milliseconds(timeoutMs);
 // Make sure we have at least one before moving forward.
 LOG_TRC("Waiting for a new child for a max of " << timeoutMs << " 
ms.");
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] online.git: Branch 'distro/collabora/collabora-online-2-1' - wsd/LOOLWSD.cpp

2017-10-05 Thread Jan Holesovsky
 wsd/LOOLWSD.cpp |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

New commits:
commit 2d2398aa06c66d0a79178becf90b28fdcc20bdfd
Author: Jan Holesovsky 
Date:   Thu Oct 5 16:12:10 2017 +0200

rlimits: Let's default to 0 when there's nothing in the config file too.

Change-Id: Ib99939a11d1e7cef112bf352b7c1dc6ac2d045c4
Reviewed-on: https://gerrit.libreoffice.org/43170
Reviewed-by: Andras Timar 
Tested-by: Andras Timar 

diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index 7b134862..e597a790 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -634,8 +634,8 @@ void LOOLWSD::initialize(Application& self)
 { "per_document.autosave_duration_secs", "300" },
 { "per_document.limit_virt_mem_mb", "0" },
 { "per_document.limit_stack_mem_kb", "8000" },
-{ "per_document.limit_file_size_mb", "50" },
-{ "per_document.limit_num_open_files", "1024" },
+{ "per_document.limit_file_size_mb", "0" },
+{ "per_document.limit_num_open_files", "0" },
 { "per_view.out_of_focus_timeout_secs", "60" },
 { "per_view.idle_timeout_secs", "900" },
 { "loleaflet_html", "loleaflet.html" },
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] online.git: Branch 'distro/collabora/collabora-online-2-1' - wsd/LOOLWSD.cpp wsd/reference.txt wsd/Storage.cpp

2017-08-02 Thread Jan Holesovsky
 wsd/LOOLWSD.cpp   |   31 ---
 wsd/Storage.cpp   |   12 
 wsd/reference.txt |7 ---
 3 files changed, 40 insertions(+), 10 deletions(-)

New commits:
commit d3a079520e531ee55ce6243e80b5a4fd400092c2
Author: Jan Holesovsky 
Date:   Wed Aug 2 18:55:43 2017 +0200

[API CHANGE] Changed how the params are passed to convert-to.

No need for the 'fromat=' parameter any more; use like:

curl -F "data=@test.txt" https://localhost:9980/lool/convert-to/pdf

Change-Id: Ic3080f821c752982f4d22b5e8043b36e6a39fff2
Reviewed-on: https://gerrit.libreoffice.org/40693
Reviewed-by: Michael Meeks 
Tested-by: Michael Meeks 

diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index 074dc643..00eb3248 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -442,9 +442,14 @@ std::shared_ptr getNewChild_Blocks()
 class ConvertToPartHandler : public PartHandler
 {
 std::string& _filename;
+
+/// Is it really a convert-to, ie. use an especially formed path?
+bool _convertTo;
+
 public:
-ConvertToPartHandler(std::string& filename)
+ConvertToPartHandler(std::string& filename, bool convertTo = false)
 : _filename(filename)
+, _convertTo(convertTo)
 {
 }
 
@@ -462,7 +467,8 @@ public:
 if (!params.has("filename"))
 return;
 
-Path tempPath = Path::forDirectory(Poco::TemporaryFile::tempName() + 
"/");
+Path tempPath = _convertTo? 
Path::forDirectory(Poco::TemporaryFile::tempName("/tmp/convert-to") + "/") :
+
Path::forDirectory(Poco::TemporaryFile::tempName() + "/");
 File(tempPath).createDirectories();
 // Prevent user inputting anything funny here.
 // A "filename" should always be a filename, not a path
@@ -1723,9 +1729,18 @@ private:
 }
 catch (const std::exception& exc)
 {
-// TODO: Send back failure.
+// Bad request.
+std::ostringstream oss;
+oss << "HTTP/1.1 400\r\n"
+<< "Date: " << 
Poco::DateTimeFormatter::format(Poco::Timestamp(), 
Poco::DateTimeFormat::HTTP_FORMAT) << "\r\n"
+<< "User-Agent: LOOLWSD WOPI Agent\r\n"
+<< "Content-Length: 0\r\n"
+<< "\r\n";
+socket->send(oss.str());
+socket->shutdown();
+
 // NOTE: Check _wsState to choose between HTTP response or 
WebSocket (app-level) error.
-LOG_ERR("#" << socket->getFD() << " Exception while processing 
incoming request: [" <<
+LOG_INF("#" << socket->getFD() << " Exception while processing 
incoming request: [" <<
 LOOLProtocol::getAbbreviatedMessage(in) << "]: " << 
exc.what());
 }
 
@@ -1851,12 +1866,14 @@ private:
 auto socket = _socket.lock();
 
 StringTokenizer tokens(request.getURI(), "/?");
-if (tokens.count() >= 3 && tokens[2] == "convert-to")
+if (tokens.count() >= 4 && tokens[2] == "convert-to")
 {
 std::string fromPath;
-ConvertToPartHandler handler(fromPath);
+ConvertToPartHandler handler(fromPath, /*convertTo =*/ true);
 HTMLForm form(request, message, handler);
-const std::string format = (form.has("format") ? 
form.get("format") : "");
+
+// extract the target format from the URI
+const std::string format = tokens[3];
 
 bool sent = false;
 if (!fromPath.empty())
diff --git a/wsd/Storage.cpp b/wsd/Storage.cpp
index 6df6744a..aac3b1d1 100644
--- a/wsd/Storage.cpp
+++ b/wsd/Storage.cpp
@@ -195,6 +195,18 @@ std::unique_ptr StorageBase::create(const 
Poco::URI& uri, const std
 {
 return std::unique_ptr(new LocalStorage(uri, 
jailRoot, jailPath));
 }
+else
+{
+std::vector pathSegments;
+Poco::URI(uri).getPathSegments(pathSegments);
+
+// guard against attempts to escape
+if (pathSegments.size() == 4 && pathSegments[0] == "tmp" && 
pathSegments[1] == "convert-to" && pathSegments[2] != ".." && pathSegments[3] 
!= "..")
+{
+LOG_INF("Public URI [" << uri.toString() << "] is actually a 
convert-to tempfile.");
+return std::unique_ptr(new LocalStorage(uri, 
jailRoot, jailPath));
+}
+}
 
 LOG_ERR("Local Storage is disabled by default. Enable in the config 
file or on the command-line to enable.");
 }
diff --git a/wsd/reference.txt b/wsd/reference.txt
index 5c706621..6f35c5cb 100644
--- a/wsd/reference.txt
+++ b/wsd/reference.txt
@@ -2,9 +2,10 @@ LibreOffice Online API
 ===
 
 Document conversion:
-- API: HTTP POST to /lool/convert-to
-- parameters: format= (see e.g. "png", "pdf" or "txt"), and 
the file itself in the 

[Libreoffice-commits] online.git: Branch 'distro/collabora/collabora-online-2-1' - wsd/LOOLWSD.cpp

2017-07-28 Thread Ashod Nakashian
 wsd/LOOLWSD.cpp |   10 +++---
 1 file changed, 3 insertions(+), 7 deletions(-)

New commits:
commit 022ecf39a976605aa0384b0568d53d023f22a905
Author: Ashod Nakashian 
Date:   Mon Jun 19 22:47:30 2017 -0400

wsd: always prespawn children when creating forkit

Also, no need for the DocBrokerMutex to be locked
in createForkit.

Change-Id: I651c50c8b5518f7b0ee0d8b15c413fc070e30443
Reviewed-on: https://gerrit.libreoffice.org/38993
Reviewed-by: Ashod Nakashian 
Tested-by: Ashod Nakashian 
(cherry picked from commit bc067c7b299ed1299b7fb4546444abf403cb6c5b)
Reviewed-on: https://gerrit.libreoffice.org/38996
Reviewed-by: Jan Holesovsky 
Tested-by: Jan Holesovsky 

diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index 098c576d..2d91d49b 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -1141,6 +1141,8 @@ bool LOOLWSD::createForKit()
 #else
 LOG_INF("Creating new forkit process.");
 
+std::unique_lock newChildrenLock(NewChildrenMutex);
+
 Process::Args args;
 args.push_back("--losubpath=" + std::string(LO_JAIL_SUBPATH));
 args.push_back("--systemplate=" + SysTemplate);
@@ -1165,10 +1167,6 @@ bool LOOLWSD::createForKit()
 args.push_back("--nocaps");
 }
 
-// If we're recovering forkit, don't allow processing new requests.
-std::unique_lock docBrokersLock(DocBrokersMutex);
-std::unique_lock newChildrenLock(NewChildrenMutex);
-
 // Always reap first, in case we haven't done so yet.
 int status;
 waitpid(ForKitProcId, , WUNTRACED | WNOHANG);
@@ -1199,6 +1197,7 @@ bool LOOLWSD::createForKit()
 // Init the Admin manager
 Admin::instance().setForKitPid(ForKitProcId);
 
+rebalanceChildren(LOOLWSD::NumPreSpawnedChildren - 1);
 return ForKitProcId != -1;
 #endif
 }
@@ -2498,9 +2497,6 @@ int LOOLWSD::innerMain()
 }
 #endif
 
-// Prefork initial children
-prespawnChildren();
-
 // Start the server.
 srv.start(ClientPortNumber);
 
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] online.git: Branch 'distro/collabora/collabora-online-2-1' - wsd/LOOLWSD.cpp

2017-07-28 Thread Ashod Nakashian
 wsd/LOOLWSD.cpp |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

New commits:
commit e23e945dcc2fafd4074ea1d7431f0f8d540133ff
Author: Ashod Nakashian 
Date:   Mon Jun 19 22:15:59 2017 -0400

wsd: avoid deadlock when restoring forkit

LOOLWSD::checkAndRestoreForKit() eventually takes
NewChildrenLock, which is also taken in getNewChild_Blocks().

Luckily, we can defer that to the Prisoner poll, which we do.

Change-Id: Ib65c0be08870d1c4c68efd72192dac2e73c79f7c
Reviewed-on: https://gerrit.libreoffice.org/38992
Reviewed-by: Ashod Nakashian 
Tested-by: Ashod Nakashian 
(cherry picked from commit c28992758d1db7f23b477178d93c2b84e9f48c06)
Reviewed-on: https://gerrit.libreoffice.org/38995
Reviewed-by: Jan Holesovsky 
Tested-by: Jan Holesovsky 

diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index b5003a5c..098c576d 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -394,9 +394,9 @@ std::shared_ptr getNewChild_Blocks()
 ++numPreSpawn; // Replace the one we'll dispatch just now.
 if (rebalanceChildren(numPreSpawn) < 0)
 {
-LOG_DBG("getNewChild: rebalancing of children failed. Checking and 
restoring forkit.");
+LOG_DBG("getNewChild: rebalancing of children failed. Scheduling 
housekeeping to recover.");
 
-LOOLWSD::checkAndRestoreForKit();
+LOOLWSD::doHousekeeping();
 
 // Let the caller retry after a while.
 return nullptr;
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] online.git: Branch 'distro/collabora/collabora-online-2-1' - wsd/LOOLWSD.cpp wsd/LOOLWSD.hpp

2017-07-18 Thread Jan Holesovsky
 wsd/LOOLWSD.cpp |6 +++---
 wsd/LOOLWSD.hpp |4 ++--
 2 files changed, 5 insertions(+), 5 deletions(-)

New commits:
commit c2a6f15426321d087c897e9fcc047b3cd945eb57
Author: Jan Holesovsky 
Date:   Mon Jul 17 19:59:46 2017 +0200

discovery: Make the unknown file extensions read-only.

Change-Id: Ie1467334868a7e4aa31aa69f67d0cd434ed18e7b
Reviewed-on: https://gerrit.libreoffice.org/40081
Reviewed-by: pranavk 
Tested-by: pranavk 

diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index 5e3ce0e4..b5003a5c 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -546,7 +546,7 @@ std::string LOOLWSD::LOKitVersion;
 std::string LOOLWSD::ConfigFile = LOOLWSD_CONFIGDIR "/loolwsd.xml";
 Util::RuntimeConstant LOOLWSD::SSLEnabled;
 Util::RuntimeConstant LOOLWSD::SSLTermination;
-std::set LOOLWSD::ViewFileExtensions;
+std::set LOOLWSD::EditFileExtensions;
 
 static std::string UnitTestLibrary;
 
@@ -2169,8 +2169,8 @@ private:
 elem->setAttribute(urlsrc, uriValue);
 
 // Set the View extensions cache as well.
-if (elem->getAttribute("name") == "view")
-LOOLWSD::ViewFileExtensions.insert(elem->getAttribute("ext"));
+if (elem->getAttribute("name") == "edit")
+LOOLWSD::EditFileExtensions.insert(elem->getAttribute("ext"));
 }
 
 std::ostringstream ostrXML;
diff --git a/wsd/LOOLWSD.hpp b/wsd/LOOLWSD.hpp
index a608c6c1..f9c3d409 100644
--- a/wsd/LOOLWSD.hpp
+++ b/wsd/LOOLWSD.hpp
@@ -55,7 +55,7 @@ public:
 static std::atomic NumConnections;
 static bool TileCachePersistent;
 static std::unique_ptr TraceDumper;
-static std::set ViewFileExtensions;
+static std::set EditFileExtensions;
 
 /// Flag to shutdown the server.
 std::atomic ShutdownFlag;
@@ -85,7 +85,7 @@ public:
 /// Return truee iff extension is marked as view action in discovery.xml.
 static bool IsViewFileExtension(const std::string& extension)
 {
-return ViewFileExtensions.find(extension) != ViewFileExtensions.end();
+return EditFileExtensions.find(extension) == EditFileExtensions.end();
 }
 
 /// Returns the value of the specified application configuration,
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] online.git: Branch 'distro/collabora/collabora-online-2-1' - wsd/LOOLWSD.cpp

2017-06-07 Thread Ashod Nakashian
 wsd/LOOLWSD.cpp |   92 +---
 1 file changed, 61 insertions(+), 31 deletions(-)

New commits:
commit e215e92e5d5b97ad8d2477513224c305a94de790
Author: Ashod Nakashian 
Date:   Tue Jun 6 22:33:21 2017 -0400

wsd: discovery.xml now preprocessed and cached

Reviewed-on: https://gerrit.libreoffice.org/38479
Reviewed-by: Ashod Nakashian 
Tested-by: Ashod Nakashian 
(cherry picked from commit 44f4ba27304387476cfd30f7531007a2fb5affb7)

Change-Id: Ie2f274452e9bd3a65061e24582a7280646162cdf
Reviewed-on: https://gerrit.libreoffice.org/38481
Reviewed-by: Jan Holesovsky 
Tested-by: Jan Holesovsky 

diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index 8ec8423b..07277e9d 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -1528,6 +1528,11 @@ public:
 {
 }
 
+static void InitStaticFileContentCache()
+{
+StaticFileContentCache["discovery.xml"] = getDiscoveryXML();
+}
+
 private:
 
 /// Set the socket associated with this ResponseClient.
@@ -1740,36 +1745,9 @@ private:
 {
 LOG_DBG("Wopi discovery request: " << request.getURI());
 
-// http://server/hosting/discovery
-std::string discoveryPath = 
Path(Application::instance().commandPath()).parent().toString() + 
"discovery.xml";
-if (!File(discoveryPath).exists())
-{
-discoveryPath = LOOLWSD::FileServerRoot + "/discovery.xml";
-}
-
-const std::string mediaType = "text/xml";
-const std::string action = "action";
-const std::string urlsrc = "urlsrc";
-const auto& config = Application::instance().config();
-const std::string loleafletHtml = config.getString("loleaflet_html", 
"loleaflet.html");
-const std::string uriValue = ((LOOLWSD::isSSLEnabled() || 
LOOLWSD::isSSLTermination()) ? "https://; : "http://;)
-   + (LOOLWSD::ServerName.empty() ? 
request.getHost() : LOOLWSD::ServerName)
-   + "/loleaflet/" LOOLWSD_VERSION_HASH "/" + 
loleafletHtml + '?';
-
-InputSource inputSrc(discoveryPath);
-DOMParser parser;
-AutoPtr docXML = parser.parse();
-AutoPtr listNodes = docXML->getElementsByTagName(action);
-
-for (unsigned long it = 0; it < listNodes->length(); ++it)
-{
-static_cast(listNodes->item(it))->setAttribute(urlsrc, 
uriValue);
-}
-
-std::ostringstream ostrXML;
-DOMWriter writer;
-writer.writeNode(ostrXML, docXML);
-const std::string xml = ostrXML.str();
+std::string xml = getFileContent("discovery.xml");
+const std::string hostname = (LOOLWSD::ServerName.empty() ? 
request.getHost() : LOOLWSD::ServerName);
+Poco::replaceInPlace(xml, std::string("%SERVER_HOST%"), hostname);
 
 // TODO: Refactor this to some common handler.
 std::ostringstream oss;
@@ -1777,7 +1755,7 @@ private:
 << "Last-Modified: " << 
Poco::DateTimeFormatter::format(Poco::Timestamp(), 
Poco::DateTimeFormat::HTTP_FORMAT) << "\r\n"
 << "User-Agent: LOOLWSD WOPI Agent\r\n"
 << "Content-Length: " << xml.size() << "\r\n"
-<< "Content-Type: " << mediaType << "\r\n"
+<< "Content-Type: text/xml\r\n"
 << "X-Content-Type-Options: nosniff\r\n"
 << "\r\n"
 << xml;
@@ -2149,12 +2127,62 @@ private:
 }
 }
 
+/// Lookup cached file content.
+const std::string& getFileContent(const std::string& filename)
+{
+const auto it = StaticFileContentCache.find(filename);
+if (it == StaticFileContentCache.end())
+{
+throw Poco::FileAccessDeniedException("Invalid or forbidden file 
path: [" + filename + "].");
+}
+
+return it->second;
+}
+
+/// Process the discovery.xml file and return as string.
+static std::string getDiscoveryXML()
+{
+// http://server/hosting/discovery
+std::string discoveryPath = 
Path(Application::instance().commandPath()).parent().toString() + 
"discovery.xml";
+if (!File(discoveryPath).exists())
+{
+discoveryPath = LOOLWSD::FileServerRoot + "/discovery.xml";
+}
+
+const std::string action = "action";
+const std::string urlsrc = "urlsrc";
+const auto& config = Application::instance().config();
+const std::string loleafletHtml = config.getString("loleaflet_html", 
"loleaflet.html");
+const std::string uriValue = ((LOOLWSD::isSSLEnabled() || 
LOOLWSD::isSSLTermination()) ? "https://; : "http://;)
+   + std::string("%SERVER_HOST%")
+   + "/loleaflet/" LOOLWSD_VERSION_HASH "/" + 
loleafletHtml + '?';
+
+

[Libreoffice-commits] online.git: Branch 'distro/collabora/collabora-online-2-1' - wsd/LOOLWSD.cpp

2017-05-17 Thread Jan Holesovsky
 wsd/LOOLWSD.cpp |9 +++--
 1 file changed, 7 insertions(+), 2 deletions(-)

New commits:
commit f31095690add2fd9f76e6400621892c03b441601
Author: Jan Holesovsky 
Date:   Wed May 17 16:28:55 2017 +0200

wsd: Don't set Content-Disposition for SVGs, the browser must handle them.

Otherwise the presesntation mode downloads them instead of showing.

Change-Id: If2c9785aa5ef6bbb65e911b834c77ea83da281e7
Reviewed-on: https://gerrit.libreoffice.org/37715
Reviewed-by: Marco Cecchetti 
Tested-by: Marco Cecchetti 

diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index a889e42a..d7179ab2 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -1995,10 +1995,15 @@ private:
 if (filePath.isAbsolute() && File(filePath).exists())
 {
 // Instruct browsers to download the file, not display it
-response.set("Content-Disposition", "attachment; filename=\"" 
+ fileName + "\"");
+// with the exception of SVG where we need the browser to
+// actually show it.
+std::string contentType = getContentType(fileName);
+if (contentType != "image/svg+xml")
+response.set("Content-Disposition", "attachment; 
filename=\"" + fileName + "\"");
+
 try
 {
-HttpHelper::sendFile(socket, filePath.toString(), 
getContentType(fileName), response);
+HttpHelper::sendFile(socket, filePath.toString(), 
contentType, response);
 responded = true;
 }
 catch (const Exception& exc)
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] online.git: Branch 'distro/collabora/collabora-online-2-1' - wsd/LOOLWSD.cpp

2017-05-16 Thread Ashod Nakashian
 wsd/LOOLWSD.cpp |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit d4b202fe4979832fe1f292735726f10b2b9f2330
Author: Ashod Nakashian 
Date:   Sun May 7 23:23:02 2017 -0400

wsd: build fix due to merge error

Change-Id: Ib1d7ce1b880c71b0b2fd8262a92e7e965211653e
Reviewed-on: https://gerrit.libreoffice.org/37375
Reviewed-by: Ashod Nakashian 
Tested-by: Ashod Nakashian 

diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index 5b3ac378..a889e42a 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -1460,7 +1460,7 @@ private:
 if (jailId.empty())
 {
 LOG_ERR("Invalid JailId in child URI [" << request.getURI() << 
"].");
-return SocketHandlerInterface::SocketOwnership::UNCHANGED;
+return;
 }
 
 in.clear();
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] online.git: Branch 'distro/collabora/collabora-online-2-1' - wsd/LOOLWSD.cpp wsd/TraceFile.hpp

2017-05-02 Thread Ashod Nakashian
 wsd/LOOLWSD.cpp   |1 -
 wsd/TraceFile.hpp |7 ---
 2 files changed, 4 insertions(+), 4 deletions(-)

New commits:
commit 16d6c1bc8f69c6f91322907b8777ccdfc21e1652
Author: Ashod Nakashian 
Date:   Mon May 1 15:33:37 2017 -0400

wsd: trace file cleanups

Change-Id: I72ccbb9f01d4e27b59d88cca9da05c1472008825
Reviewed-on: https://gerrit.libreoffice.org/37130
Reviewed-by: Ashod Nakashian 
Tested-by: Ashod Nakashian 
(cherry picked from commit c31bf89976a14d5dbfb8c4bd012f959284c9344b)
Reviewed-on: https://gerrit.libreoffice.org/37151
Reviewed-by: Jan Holesovsky 
Tested-by: Jan Holesovsky 

diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index b4db3636..c6e009c8 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -787,7 +787,6 @@ void LOOLWSD::initialize(Application& self)
 const auto compress = getConfigValue(conf, 
"trace.path[@compress]", false);
 const auto takeSnapshot = getConfigValue(conf, 
"trace.path[@snapshot]", false);
 TraceDumper.reset(new TraceFileWriter(path, recordOutgoing, compress, 
takeSnapshot, filters));
-LOG_INF("Command trace dumping enabled to file: " << path);
 }
 
 StorageBase::initialize();
diff --git a/wsd/TraceFile.hpp b/wsd/TraceFile.hpp
index 23d46763..d19c0103 100644
--- a/wsd/TraceFile.hpp
+++ b/wsd/TraceFile.hpp
@@ -35,7 +35,7 @@ public:
 Invalid = 0,
 Incoming = '>',
 Outgoing = '<',
-Event = '-'
+Event = '~'
 };
 
 TraceFileRecord() :
@@ -115,7 +115,7 @@ public:
 // Create a snapshot file.
 const Poco::Path origPath(localPath);
 std::string filename = origPath.getBaseName();
-filename += '_' + 
Poco::DateTimeFormatter::format(Poco::DateTime(), "%Y%m%d_%H~%M~%S");
+filename += '_' + 
Poco::DateTimeFormatter::format(Poco::DateTime(), "%Y%m%d_%H-%M-%S");
 filename += '.' + origPath.getExtension();
 snapshot = Poco::Path(_path, filename).toString();
 
@@ -273,8 +273,9 @@ private:
 }
 
 std::string res = path.substr(0, pos);
-res += Poco::DateTimeFormatter::format(Poco::DateTime(), 
"%Y%m%d_%H~%M~%S");
+res += Poco::DateTimeFormatter::format(Poco::DateTime(), 
"%Y%m%d_%H-%M-%S");
 res += path.substr(pos + 1);
+LOG_INF("Command trace dumping enabled to file: " << res);
 return res;
 }
 
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] online.git: Branch 'distro/collabora/collabora-online-2-1' - wsd/LOOLWSD.cpp

2017-04-20 Thread Jan Holesovsky
 wsd/LOOLWSD.cpp |   14 ++
 1 file changed, 6 insertions(+), 8 deletions(-)

New commits:
commit 998473fa7fe6dfb68f202a464a1bb12d417d92a2
Author: Jan Holesovsky 
Date:   Thu Apr 20 17:42:31 2017 +0200

Revert "wsd: clear the incoming buffer before upgrading to WS"

This fixes image insertion.

This reverts commit 9a761ffe68b24e180dd74c0737e20cabe9dc9e1b.

Change-Id: I05c88b96e40fce820a75738485fe8599129d3e20

diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index d109e5d2..b4db3636 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -1533,7 +1533,6 @@ private:
 {
 auto socket = _socket.lock();
 std::vector& in = socket->_inBuffer;
-LOG_TRC("#" << socket->getFD() << " handling incoming " << in.size() 
<< " bytes.");
 
 // Find the end of the header, if any.
 static const std::string marker("\r\n\r\n");
@@ -1541,7 +1540,7 @@ private:
   marker.begin(), marker.end());
 if (itBody == in.end())
 {
-LOG_DBG("#" << socket->getFD() << " doesn't have enough data 
yet.");
+LOG_TRC("#" << socket->getFD() << " doesn't have enough data 
yet.");
 return SocketHandlerInterface::SocketOwnership::UNCHANGED;
 }
 
@@ -1579,10 +1578,6 @@ private:
 LOG_DBG("Not enough content yet: ContentLength: " << 
contentLength << ", available: " << available);
 return SocketHandlerInterface::SocketOwnership::UNCHANGED;
 }
-
-// if we succeeded - remove the request from our input buffer
-// we expect one request per socket
-in.erase(in.begin(), itBody);
 }
 catch (const std::exception& exc)
 {
@@ -1639,8 +1634,7 @@ private:
 // All post requests have url prefix 'lool'.
 socketOwnership = handlePostRequest(request, message);
 }
-else if (reqPathTokens.count() > 2 && reqPathTokens[0] == 
"lool" && reqPathTokens[2] == "ws" &&
- request.find("Upgrade") != request.end() && 
Poco::icompare(request["Upgrade"], "websocket") == 0)
+else if (reqPathTokens.count() > 2 && reqPathTokens[0] == 
"lool" && reqPathTokens[2] == "ws")
 {
 socketOwnership = handleClientWsUpgrade(request, 
reqPathTokens[1]);
 }
@@ -1659,6 +1653,10 @@ private:
 socket->shutdown();
 }
 }
+
+// if we succeeded - remove the request from our input buffer
+// we expect one request per socket
+in.clear();
 }
 catch (const std::exception& exc)
 {
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] online.git: Branch 'distro/collabora/collabora-online-2-1' - wsd/LOOLWSD.cpp

2017-04-19 Thread Ashod Nakashian
 wsd/LOOLWSD.cpp |4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

New commits:
commit 28063e00a77091176102a191726e57835d26b7d6
Author: Ashod Nakashian 
Date:   Sun Apr 16 23:47:46 2017 -0400

wsd: take DocBrokers lock before broadcasting diskfull

alertAllUsersInternal does not have the DocBrokersMutex
when called from forkChildren, which was intentionally
removed a while back since it's not normally necessary.
That is, unless we have diskfull situation and need
to broadcast to clients.

We now take the lock explicitly in alertAllUsersInternal
before enumerating DocBrokers to broadcast the notification
to the user, since there is no use case for calling
it under that lock now.

Change-Id: I4f7cccb1112c17091d1039441af4c84d5d13d059
Reviewed-on: https://gerrit.libreoffice.org/36601
Reviewed-by: Ashod Nakashian 
Tested-by: Ashod Nakashian 
(cherry picked from commit 6023fdc3c70a2d2aad2c98c8e739f19d7a630e8b)
Reviewed-on: https://gerrit.libreoffice.org/36611
Reviewed-by: Jan Holesovsky 
Tested-by: Jan Holesovsky 

diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index e42010a1..c432a862 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -209,7 +209,7 @@ inline void shutdownLimitReached(WebSocketHandler& ws)
 /// connected to any document.
 void alertAllUsersInternal(const std::string& msg)
 {
-Util::assertIsLocked(DocBrokersMutex);
+std::lock_guard docBrokersLock(DocBrokersMutex);
 
 LOG_INF("Alerting all users: [" << msg << "]");
 
@@ -2575,8 +2575,6 @@ void alertAllUsers(const std::string& cmd, const 
std::string& kind)
 
 void alertAllUsers(const std::string& msg)
 {
-std::lock_guard docBrokersLock(DocBrokersMutex);
-
 alertAllUsersInternal(msg);
 }
 
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] online.git: Branch 'distro/collabora/collabora-online-2-1' - wsd/LOOLWSD.cpp

2017-04-13 Thread Miklos Vajna
 wsd/LOOLWSD.cpp |2 --
 1 file changed, 2 deletions(-)

New commits:
commit 17207ed31fa986e1abfe3e18c6bf6562859cf682
Author: Miklos Vajna 
Date:   Thu Apr 13 10:31:17 2017 +0200

wsd: remove unused using declarations in LOOLWSD

Change-Id: Id8a7f94cef0ab34fb7d789adff92b9c822af62c2
Reviewed-on: https://gerrit.libreoffice.org/36514
Reviewed-by: Jan Holesovsky 
Tested-by: Jan Holesovsky 

diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index 9d3c62fe..5112e9ae 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -130,7 +130,6 @@ using Poco::Net::MessageHeader;
 using Poco::Net::NameValueCollection;
 using Poco::Net::PartHandler;
 using Poco::Net::SocketAddress;
-using Poco::Net::WebSocket;
 using Poco::Path;
 #ifndef KIT_IN_PROCESS
 using Poco::Pipe;
@@ -145,7 +144,6 @@ using Poco::TemporaryFile;
 #if FUZZER
 using Poco::Thread;
 #endif
-using Poco::ThreadPool;
 using Poco::URI;
 using Poco::Util::Application;
 using Poco::Util::HelpFormatter;
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] online.git: Branch 'distro/collabora/collabora-online-2-1' - wsd/LOOLWSD.cpp

2017-04-12 Thread Ashod Nakashian
 wsd/LOOLWSD.cpp |6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

New commits:
commit 156493efc34113d9a373b3e0d0669f8814232cee
Author: Ashod Nakashian 
Date:   Tue Apr 11 23:18:33 2017 -0400

wsd: avoid miscounting outstanding child forks

The number of outstanding child forks can
become negative if more children are
spawned than requested.

This prevents such a scenario from
permanently preventing WSD from spawning
new children, which happens when
OutstandingForks is negative.

Change-Id: Ief1e56d7b4a079e097ca2d18bd90a01d935f6b30
Reviewed-on: https://gerrit.libreoffice.org/36437
Reviewed-by: Ashod Nakashian 
Tested-by: Ashod Nakashian 
(cherry picked from commit 1752dd74d61aeb17c826be28b167d3e7169d0189)
Reviewed-on: https://gerrit.libreoffice.org/36438
Reviewed-by: Jan Holesovsky 
Tested-by: Jan Holesovsky 

diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index d5a7fd0b..57c63523 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -332,7 +332,7 @@ static int rebalanceChildren(int balance)
 
 const auto duration = (std::chrono::steady_clock::now() - 
LastForkRequestTime);
 const auto durationMs = 
std::chrono::duration_cast(duration).count();
-if (OutstandingForks > 0 && durationMs >= CHILD_TIMEOUT_MS)
+if (OutstandingForks != 0 && durationMs >= CHILD_TIMEOUT_MS)
 {
 // Children taking too long to spawn.
 // Forget we had requested any, and request anew.
@@ -371,6 +371,10 @@ static size_t addNewChild(const 
std::shared_ptr& child)
 std::unique_lock lock(NewChildrenMutex);
 
 --OutstandingForks;
+// Prevent from going -ve if we have unexpected children.
+if (OutstandingForks < 0)
+++OutstandingForks;
+
 NewChildren.emplace_back(child);
 const auto count = NewChildren.size();
 LOG_INF("Have " << count << " spare " <<
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] online.git: Branch 'distro/collabora/collabora-online-2-1' - wsd/LOOLWSD.cpp

2017-04-11 Thread Ashod Nakashian
 wsd/LOOLWSD.cpp |   15 +--
 1 file changed, 9 insertions(+), 6 deletions(-)

New commits:
commit 1890d2ee134ace63a28b05361724d5b8a56b67bb
Author: Ashod Nakashian 
Date:   Sun Apr 9 18:28:00 2017 -0400

wsd: clear the incoming buffer before upgrading to WS

There was an interesting race when we cleared the
inBuffer after the WS upgrade. Since during the
upgrade we also transfer the socket to the DocBroker,
which has its own poll thread, the DocBroker poll
could trigger a POLLIN event if data comes
while the handler (that is handling the WS upgrad
and transfer to DocBroker) hasn't got to the point
where it clears the inBuffer of the data we just
read (i.e. the HTTP GET request). Even if not
the case, after transfering a socket to another
poll thread the socket buffers should not be
touched.

Here we move the inBuffer clearing to be as soon
as we have successfully parsed the request and
are ready to process it.

Also, we don't clear the full buffer, in case
we had read into the buffer both the requst
and the first message, if the thread was switched
out right after getting the POLLIN but before
reading from the socket, giving enough time to
receive more data and reading it together with
first read (which is the request).

Change-Id: I9888d4c2b70d2e433824818bbe7f69f13742486c
Reviewed-on: https://gerrit.libreoffice.org/36326
Reviewed-by: Ashod Nakashian 
Tested-by: Ashod Nakashian 
(cherry picked from commit 9a761ffe68b24e180dd74c0737e20cabe9dc9e1b)
Reviewed-on: https://gerrit.libreoffice.org/36340
Reviewed-by: Jan Holesovsky 
Tested-by: Jan Holesovsky 

diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index aa00d0ba..7b54bfd2 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -1525,6 +1525,7 @@ private:
 {
 auto socket = _socket.lock();
 std::vector& in = socket->_inBuffer;
+LOG_TRC("#" << socket->getFD() << " handling incoming " << in.size() 
<< " bytes.");
 
 // Find the end of the header, if any.
 static const std::string marker("\r\n\r\n");
@@ -1532,7 +1533,7 @@ private:
   marker.begin(), marker.end());
 if (itBody == in.end())
 {
-LOG_TRC("#" << socket->getFD() << " doesn't have enough data 
yet.");
+LOG_DBG("#" << socket->getFD() << " doesn't have enough data 
yet.");
 return SocketHandlerInterface::SocketOwnership::UNCHANGED;
 }
 
@@ -1570,6 +1571,10 @@ private:
 LOG_DBG("Not enough content yet: ContentLength: " << 
contentLength << ", available: " << available);
 return SocketHandlerInterface::SocketOwnership::UNCHANGED;
 }
+
+// if we succeeded - remove the request from our input buffer
+// we expect one request per socket
+in.erase(in.begin(), itBody);
 }
 catch (const std::exception& exc)
 {
@@ -1626,7 +1631,8 @@ private:
 // All post requests have url prefix 'lool'.
 socketOwnership = handlePostRequest(request, message);
 }
-else if (reqPathTokens.count() > 2 && reqPathTokens[0] == 
"lool" && reqPathTokens[2] == "ws")
+else if (reqPathTokens.count() > 2 && reqPathTokens[0] == 
"lool" && reqPathTokens[2] == "ws" &&
+ request.find("Upgrade") != request.end() && 
Poco::icompare(request["Upgrade"], "websocket") == 0)
 {
 socketOwnership = handleClientWsUpgrade(request, 
reqPathTokens[1]);
 }
@@ -1645,15 +1651,12 @@ private:
 socket->shutdown();
 }
 }
-
-// if we succeeded - remove the request from our input buffer
-// we expect one request per socket
-in.clear();
 }
 catch (const std::exception& exc)
 {
 // TODO: Send back failure.
 // NOTE: Check _wsState to choose between HTTP response or 
WebSocket (app-level) error.
+LOG_ERR("#" << socket->getFD() << " Exception while processing 
incoming request: [" << LOOLProtocol::getAbbreviatedMessage(in) << "]");
 }
 
 return socketOwnership;
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] online.git: Branch 'distro/collabora/collabora-online-2-1' - wsd/LOOLWSD.cpp

2017-04-11 Thread Ashod Nakashian
 wsd/LOOLWSD.cpp |   18 +-
 1 file changed, 5 insertions(+), 13 deletions(-)

New commits:
commit f411100a522040e8826f599e66f1f9a2c38d2dda
Author: Ashod Nakashian 
Date:   Sun Apr 9 18:27:25 2017 -0400

wsd: remove outdated comment and simplify

Change-Id: I47e8b22708ab64ad95aa681407344686e6d4eb9d
Reviewed-on: https://gerrit.libreoffice.org/36325
Reviewed-by: Ashod Nakashian 
Tested-by: Ashod Nakashian 
(cherry picked from commit bc41ad9bf96722b9ec2654f4e54a052f5b56d52e)
Reviewed-on: https://gerrit.libreoffice.org/36339
Reviewed-by: Jan Holesovsky 
Tested-by: Jan Holesovsky 

diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index 0f91598e..aa00d0ba 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -1475,28 +1475,20 @@ private:
 if (UnitWSD::get().filterChildMessage(data))
 return;
 
+const std::string abbr = getAbbreviatedMessage(data);
 auto socket = _socket.lock();
 if (socket)
-LOG_TRC("#" << socket->getFD() << " Prisoner message [" << 
getAbbreviatedMessage([0], data.size()) << "].");
+LOG_TRC("#" << socket->getFD() << " Prisoner message [" << abbr << 
"].");
 else
 LOG_WRN("Message handler called but without valid socket.");
 
 auto child = _childProcess.lock();
 auto docBroker = child ? child->getDocumentBroker() : nullptr;
 if (docBroker)
-{
-// We should never destroy the broker, since
-// it owns us and will wait on this thread.
-// This is true with non-blocking since this is
-// called from DocumentBroker::pollThread.
-assert(docBroker.use_count() > 1);
 docBroker->handleInput(data);
-return;
-}
-
-LOG_WRN("Child " << child->getPid() <<
-" has no DocumentBroker to handle message: [" <<
-LOOLProtocol::getAbbreviatedMessage(data) << "].");
+else
+LOG_WRN("Child " << child->getPid() <<
+" has no DocumentBroker to handle message: [" << abbr << 
"].");
 }
 
 int getPollEvents(std::chrono::steady_clock::time_point /* now */,
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] online.git: Branch 'distro/collabora/collabora-online-2-1' - wsd/LOOLWSD.cpp

2017-04-05 Thread Ashod Nakashian
 wsd/LOOLWSD.cpp |   28 
 1 file changed, 16 insertions(+), 12 deletions(-)

New commits:
commit d167d2b06af62303a97bf503201d4874010121ac
Author: Ashod Nakashian 
Date:   Wed Apr 5 00:21:49 2017 -0400

wsd: correctly search for available prisoner port

Search for the next 100 ports for a usable one
and pass the one found to forkit so it connects
on that one instead of the default.

Change-Id: I26697dd8b5a35992f9e000a35ad5b44c3a3699dd
Reviewed-on: https://gerrit.libreoffice.org/36114
Reviewed-by: Ashod Nakashian 
Tested-by: Ashod Nakashian 
(cherry picked from commit 2576f9c4e9dc8a4e7eb084b4bc74055f0c92e850)
Reviewed-on: https://gerrit.libreoffice.org/36123

diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index afa59707..a1d7ec61 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -2163,7 +2163,7 @@ public:
 stop();
 }
 
-void startPrisoners(const int port)
+void startPrisoners(int& port)
 {
 PrisonerPoll.insertNewSocket(findPrisonerServerPort(port));
 PrisonerPoll.startThread();
@@ -2245,31 +2245,27 @@ private:
 
 if (!serverSocket->bind(addr))
 {
-LOG_ERR("Failed to bind to: " << addr.toString());
+LOG_SYS("Failed to bind to: " << addr.toString());
 return nullptr;
 }
 
 if (serverSocket->listen())
 return serverSocket;
 
-LOG_ERR("Failed to listen on: " << addr.toString());
+LOG_SYS("Failed to listen on: " << addr.toString());
 return nullptr;
 }
 
-std::shared_ptr findPrisonerServerPort(int port)
+std::shared_ptr findPrisonerServerPort(int& port)
 {
 std::shared_ptr factory = 
std::make_shared();
+
+LOG_INF("Trying to listen on prisoner port " << port << ".");
 std::shared_ptr socket = 
getServerSocket(SocketAddress("127.0.0.1", port),
PrisonerPoll, 
factory);
 
-if (!UnitWSD::isUnitTesting() && !socket)
-{
-LOG_FTL("Failed to listen on Prisoner master port (" <<
-MasterPortNumber << "). Exiting.");
-_exit(Application::EXIT_SOFTWARE);
-}
-
-while (!socket)
+// If we fail, try the next 100 ports.
+for (int i = 0; i < 100 && !socket; ++i)
 {
 ++port;
 LOG_INF("Prisoner port " << (port - 1) << " is busy, trying " << 
port << ".");
@@ -2277,6 +2273,14 @@ private:
  PrisonerPoll, factory);
 }
 
+if (!UnitWSD::isUnitTesting() && !socket)
+{
+LOG_FTL("Failed to listen on Prisoner port (" <<
+MasterPortNumber << '-' << port << "). Exiting.");
+_exit(Application::EXIT_SOFTWARE);
+}
+
+LOG_INF("Listening to prisoner connections on port " << port);
 return socket;
 }
 
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] online.git: Branch 'distro/collabora/collabora-online-2-1' - wsd/LOOLWSD.cpp

2017-03-31 Thread Andras Timar
 wsd/LOOLWSD.cpp |4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

New commits:
commit 8078e5b579bd8970bb3fbbb710a0a17ce9226cea
Author: Andras Timar 
Date:   Fri Mar 31 07:51:30 2017 +0200

add missing default config values

Change-Id: Ic7829c8f97f43bf8f4f2ba4eccdbdf1da89665e4
(cherry picked from commit ec5fb2a794738b84a4dae7790726be07ab56bfda)
Signed-off-by: Andras Timar 

diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index 9a5920d2..f3a644c1 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -675,7 +675,9 @@ void LOOLWSD::initialize(Application& self)
 { "logging.file.property[2]", "true" },
 { "logging.file.property[3][@name]", "flush" },
 { "logging.file.property[3]", "false" },
-{ "trace[@enable]", "false" } };
+{ "trace[@enable]", "false" },
+{ "trace.path[@compress]", "true" },
+{ "trace.path[@snapshot]", "false" } };
 
 // Set default values, in case they are missing from the config file.
 AutoPtr defConfig(new AppConfigMap(DefAppConfig));
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits