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

2020-09-18 Thread Miklos Vajna (via logerrit)
 wsd/LOOLWSD.cpp |   14 +++---
 wsd/LOOLWSD.hpp |2 +-
 2 files changed, 8 insertions(+), 8 deletions(-)

New commits:
commit 92543758a7858dea4213a5557f4ec69c426f5235
Author: Miklos Vajna 
AuthorDate: Fri Sep 18 11:03:17 2020 +0200
Commit: Miklos Vajna 
CommitDate: Fri Sep 18 14:05:37 2020 +0200

wsd: mark these functions as static

So that it's more obvious that they don't even read the state of the
object.

Change-Id: I71d39bf3a20989c8fbf3410c2f1d2a98661c49d5
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/102986
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Miklos Vajna 

diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index 2e37618d3..9d89727ae 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -2264,7 +2264,7 @@ public:
 }
 
 /// Does this address feature in the allowed hosts list.
-bool allowPostFrom(const std::string )
+static bool allowPostFrom(const std::string )
 {
 static bool init = false;
 static Util::RegexListMatcher hosts;
@@ -2627,7 +2627,7 @@ private:
 LOG_INF("Sent / response successfully.");
 }
 
-void handleFaviconRequest(const RequestDetails ,
+static void handleFaviconRequest(const RequestDetails ,
   const std::shared_ptr& socket)
 {
 assert(socket && "Must have a valid socket");
@@ -2701,7 +2701,7 @@ private:
 LOG_INF("Sent capabilities.json successfully.");
 }
 
-void handleClipboardRequest(const Poco::Net::HTTPRequest& request,
+static void handleClipboardRequest(const Poco::Net::HTTPRequest& request,
 Poco::MemoryInputStream& message,
 SocketDisposition ,
 const std::shared_ptr& socket)
@@ -2800,7 +2800,7 @@ private:
 }
 }
 
-void handleRobotsTxtRequest(const Poco::Net::HTTPRequest& request,
+static void handleRobotsTxtRequest(const Poco::Net::HTTPRequest& request,
 const std::shared_ptr& socket)
 {
 assert(socket && "Must have a valid socket");
@@ -3442,7 +3442,7 @@ private:
 }
 
 /// Lookup cached file content.
-const std::string& getFileContent(const std::string& filename)
+static const std::string& getFileContent(const std::string& filename)
 {
 const auto it = StaticFileContentCache.find(filename);
 if (it == StaticFileContentCache.end())
@@ -3650,7 +3650,7 @@ public:
 PrisonerPoll.insertNewSocket(findPrisonerServerPort());
 }
 
-void stopPrisoners()
+static void stopPrisoners()
 {
 PrisonerPoll.joinThread();
 }
@@ -3774,7 +3774,7 @@ private:
 
 /// Create a new server socket - accepted sockets will be added
 /// to the @clientSockets' poll when created with @factory.
-std::shared_ptr getServerSocket(ServerSocket::Type type, int 
port,
+static std::shared_ptr getServerSocket(ServerSocket::Type 
type, int port,
   SocketPoll ,
   const 
std::shared_ptr& factory)
 {
diff --git a/wsd/LOOLWSD.hpp b/wsd/LOOLWSD.hpp
index 7f1e05a27..1b831e250 100644
--- a/wsd/LOOLWSD.hpp
+++ b/wsd/LOOLWSD.hpp
@@ -427,7 +427,7 @@ protected:
 int main(const std::vector& args) override;
 
 /// Handle various global static destructors.
-void cleanup();
+static void cleanup();
 
 private:
 #if ENABLE_SSL
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2020-09-16 Thread Szymon Kłos (via logerrit)
 wsd/LOOLWSD.cpp |5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

New commits:
commit 87aad0a8bbf86502658ffcf3d0ee053af922d474
Author: Szymon Kłos 
AuthorDate: Wed Sep 16 16:41:09 2020 +0200
Commit: Szymon Kłos 
CommitDate: Wed Sep 16 17:31:59 2020 +0200

Decode file name when trying to download file

Simplified download process (ab162b6f9580315700a01c3bc10becd510a2ead4)
introduced a bug. Trying to download file with eg. space in the name
become impossible. This patch decodes the string to fix the issue.

Change-Id: I8e5d98010cf098b889eddcce4ba1ce65367b15d5
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/102874
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Szymon Kłos 

diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index 579267e5e..2e37618d3 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -3124,7 +3124,10 @@ private:
 
 bool foundDownloadId = !url.empty();
 
-const Path filePath(LOOLWSD::ChildRoot + jailId + 
JAILED_DOCUMENT_ROOT + url);
+std::string decoded;
+Poco::URI::decode(url, decoded);
+
+const Path filePath(LOOLWSD::ChildRoot + jailId + 
JAILED_DOCUMENT_ROOT + decoded);
 const std::string filePathAnonym = 
LOOLWSD::anonymizeUrl(filePath.toString());
 
 if (foundDownloadId && filePath.isAbsolute() && 
File(filePath).exists())
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2020-08-10 Thread Gökhan Karabulut (via logerrit)
 wsd/LOOLWSD.cpp |8 
 1 file changed, 8 insertions(+)

New commits:
commit e2e638c468f35322fc123664fd749b199f531780
Author: Gökhan Karabulut 
AuthorDate: Sat Aug 8 23:05:17 2020 +0300
Commit: Michael Meeks 
CommitDate: Mon Aug 10 12:20:08 2020 +0200

tdf#124478: Log maximum file descriptor related limits

The number of available file descriptors in a system limits the number
of documents we can open. We use an fd for client connection, another fd
for communication with a kit process and a wakeup pipe with 2 fds.
Therefore, we are left with the maximum number of fds divided by 4
documents. Out of these documents, reserve 8 (i.e., 32 fds) and log the
remaining number of documents allowed by the system. Note that Online
instance can further configure a limit for the maximum number of open
documents, which is also logged.

Also log the maximum file descriptor allowed by the system, which is the
number of available file descriptors - 1.

Change-Id: I3972690a6c9995e8d74dcfe25fe87b1ef4c33d4b
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/100393
Tested-by: Jenkins
Tested-by: Jenkins CollaboraOffice 
Tested-by: Michael Meeks 
Reviewed-by: Michael Meeks 

diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index 02feb23b7..b8c75e5b5 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -41,6 +41,7 @@
 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -1327,6 +1328,13 @@ void LOOLWSD::initialize(Application& self)
 LOOLWSD::MaxDocuments = LOOLWSD::MaxConnections;
 }
 
+struct rlimit rlim;
+::getrlimit(RLIMIT_NOFILE, );
+LOG_INF("Maximum file descriptor supported by the system: " << 
rlim.rlim_cur - 1);
+// 4 fds per document are used for client connection, Kit process 
communication, and
+// a wakeup pipe with 2 fds. 32 fds (i.e. 8 documents) are reserved.
+LOG_INF("Maximum number of open documents supported by the system: " << 
rlim.rlim_cur / 4 - 8);
+
 LOG_INF("Maximum concurrent open Documents limit: " << 
LOOLWSD::MaxDocuments);
 LOG_INF("Maximum concurrent client Connections limit: " << 
LOOLWSD::MaxConnections);
 
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2020-07-16 Thread Tor Lillqvist (via logerrit)
 wsd/LOOLWSD.cpp |   12 +++-
 1 file changed, 11 insertions(+), 1 deletion(-)

New commits:
commit 03697b3bb524e7517a8f778f951ef65d05805b9f
Author: Tor Lillqvist 
AuthorDate: Thu Jul 16 17:42:09 2020 +0300
Commit: Tor Lillqvist 
CommitDate: Thu Jul 16 22:56:47 2020 +0200

The socket inbuffer is not nul terminated

We can't just call strtoul() to parse the number at the end of the
buffer. The buffer might be followed by other digits in memory. In
that case we would get a completely wrong mobileAppDocId which will
lead to a crash or assertion failure.

Change-Id: I71c96323faa2b069009e5eda7a7153148b78094a
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/98914
Tested-by: Jenkins
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Tor Lillqvist 

diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index 7c353e6b1..b61649970 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -2555,7 +2555,17 @@ private:
 // The "app document id", the numeric id of the document, from the 
appDocIdCounter in CODocument.mm.
 char *space = strchr(socket->getInBuffer().data(), ' ');
 assert(space != nullptr);
-unsigned appDocId = std::strtoul(space + 1, nullptr, 10);
+
+// The socket buffer is not nul-terminated so we can't just call 
strtoull() on the number at
+// its end, it might be followed in memory by more digits. Is there 
really no better way to
+// parse the number at the end of the buffer than to copy the bytes 
into a nul-terminated
+// buffer?
+const size_t appDocIdLen = (socket->getInBuffer().data() + 
socket->getInBuffer().size()) - (space + 1);
+char *appDocIdBuffer = (char *)malloc(appDocIdLen + 1);
+memcpy(appDocIdBuffer, space + 1, appDocIdLen);
+appDocIdBuffer[appDocIdLen] = '\0';
+unsigned appDocId = std::strtoul(appDocIdBuffer, nullptr, 10);
+free(appDocIdBuffer);
 
 handleClientWsUpgrade(
 request, std::string(socket->getInBuffer().data(), space - 
socket->getInBuffer().data()),
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2020-07-15 Thread Tor Lillqvist (via logerrit)
 wsd/LOOLWSD.cpp |9 +++--
 1 file changed, 7 insertions(+), 2 deletions(-)

New commits:
commit d7453ac243508b96fcda32a21a8de156d6242df6
Author: Tor Lillqvist 
AuthorDate: Wed Jul 15 12:44:52 2020 +0300
Commit: Tor Lillqvist 
CommitDate: Wed Jul 15 12:59:31 2020 +0200

Attempt to fix Android build: endLoadResult() can't be inside #if MOBILEAPP

Also helps the iOS build, but there is another recent change that
broke it more.

Change-Id: If750bfa3e89ee07d97a91996223012e309b0b712
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/98811
Tested-by: Tor Lillqvist 
Reviewed-by: Tor Lillqvist 

diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index 1df218e83..7c353e6b1 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -690,6 +690,13 @@ inline std::string getServiceURI(const std::string , 
bool asAdmin = false)
 
 #endif
 
+} // anonymous namespace
+
+#endif // MOBILEAPP
+
+namespace
+{
+
 void sendLoadResult(std::shared_ptr clientSession, bool success,
 const std::string )
 {
@@ -706,8 +713,6 @@ void sendLoadResult(std::shared_ptr 
clientSession, bool success,
 
 } // anonymous namespace
 
-#endif // MOBILEAPP
-
 std::atomic LOOLWSD::NextConnectionId(1);
 
 #if !MOBILEAPP
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2020-07-05 Thread Dennis Francis (via logerrit)
 wsd/LOOLWSD.cpp |   14 ++
 1 file changed, 14 insertions(+)

New commits:
commit a22392d8270de5d6aa411d88e8202a199347ebcf
Author: Dennis Francis 
AuthorDate: Wed May 20 01:28:50 2020 +0530
Commit: Dennis Francis 
CommitDate: Sun Jul 5 10:09:40 2020 +0200

supress clang -Wparentheses-equality for WIF*() spurious case

Change-Id: I213ba6085aa1b662d5a6283cf9d84742bce288e1
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/97971
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Dennis Francis 

diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index 90be88646..9815e4158 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -1636,6 +1636,15 @@ bool LOOLWSD::checkAndRestoreForKit()
 return false;
 #else
 
+// clang issues warning for WIF*() macro usages below:
+// "equality comparison with extraneous parentheses 
[-Werror,-Wparentheses-equality]"
+// https://bugs.llvm.org/show_bug.cgi?id=22949
+
+#if defined __clang__
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wparentheses-equality"
+#endif
+
 if (ForKitProcId == -1)
 {
 // Fire the ForKit process for the first time.
@@ -1713,6 +1722,11 @@ bool LOOLWSD::checkAndRestoreForKit()
 }
 
 return false;
+
+#if defined __clang__
+#pragma clang diagnostic pop
+#endif
+
 #endif
 }
 
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2020-07-02 Thread Ashod Nakashian (via logerrit)
 wsd/LOOLWSD.cpp |   33 ++---
 1 file changed, 14 insertions(+), 19 deletions(-)

New commits:
commit 3cee55872ba7a6c59126a13373e2cd3852fda932
Author: Ashod Nakashian 
AuthorDate: Wed Jun 3 10:39:25 2020 -0400
Commit: Ashod Nakashian 
CommitDate: Thu Jul 2 21:47:08 2020 +0200

wsd: minor cleanup

* Use const where possible.
* Remove dead-code (clang-tidy error).
* Don't use hungarian notation.
* Avoid single-use variables (if redundant).
* Declare variables closest to use-site.
* Avoid unecessary temporaries.
* Avoid explicit true/false when the statement is boolean already.

Change-Id: I154dc2a7d4bcbd39f73f42e12a101a7e4eb0fd33
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/96378
Tested-by: Jenkins CollaboraOffice 
Tested-by: Jenkins
Reviewed-by: Muhammet Kara 
Reviewed-by: Ashod Nakashian 

diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index 6efb55655..da8487ddd 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -2802,14 +2802,12 @@ private:
 
 static bool isSpreadsheet(const std::string& fileName)
 {
-std::string sContentType = getContentType(fileName);
+const std::string sContentType = getContentType(fileName);
 
-if (sContentType == "application/vnd.oasis.opendocument.spreadsheet"
-|| sContentType == 
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
-|| sContentType == "application/vnd.ms-excel")
-return true;
-else
-return false;
+return sContentType == "application/vnd.oasis.opendocument.spreadsheet"
+   || sContentType
+  == 
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
+   || sContentType == "application/vnd.ms-excel";
 }
 
 void handlePostRequest(const RequestDetails ,
@@ -2844,29 +2842,26 @@ private:
 ConvertToPartHandler handler(/*convertTo =*/ true);
 HTMLForm form(request, message, handler);
 
-std::string sOptions;
 std::string format = (form.has("format") ? form.get("format") : 
"");
-std::string sFullSheetPreview = (form.has("FullSheetPreview") ? 
form.get("FullSheetPreview") : "");
-bool bFullSheetPreview = sFullSheetPreview == "true" ? true : 
false;
-
 // prefer what is in the URI
 if (requestDetails.size() > 2)
 format = requestDetails[2];
 
-std::string fromPath = handler.getFilename();
+const std::string fromPath = handler.getFilename();
 LOG_INF("Conversion request for URI [" << fromPath << "] format [" 
<< format << "].");
 if (!fromPath.empty() && !format.empty())
 {
 Poco::URI uriPublic = DocumentBroker::sanitizeURI(fromPath);
 const std::string docKey = 
DocumentBroker::getDocKey(uriPublic);
 
-if (bFullSheetPreview && format == "pdf" && 
isSpreadsheet(fromPath))
-{
-sOptions += std::string(",FullSheetPreview=") + 
sFullSheetPreview + std::string("FULLSHEETPREVEND");
-}
-else
+std::string options;
+const bool fullSheetPreview
+= (form.has("FullSheetPreview") && 
form.get("FullSheetPreview") == "true");
+if (fullSheetPreview && format == "pdf" && 
isSpreadsheet(fromPath))
 {
-bFullSheetPreview = false;
+//FIXME: We shouldn't have "true" as having the option 
already implies that
+// we want it enabled (i.e. we shouldn't set the option if 
we don't want it).
+options = ",FullSheetPreview=trueFULLSHEETPREVEND";
 }
 
 // This lock could become a bottleneck.
@@ -2874,7 +2869,7 @@ private:
 std::unique_lock docBrokersLock(DocBrokersMutex);
 
 LOG_DBG("New DocumentBroker for docKey [" << docKey << "].");
-auto docBroker = std::make_shared(fromPath, 
uriPublic, docKey, format, sOptions);
+auto docBroker = std::make_shared(fromPath, 
uriPublic, docKey, format, options);
 handler.takeFile();
 
 cleanupDocBrokers();
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2020-07-01 Thread Tor Lillqvist (via logerrit)
 wsd/LOOLWSD.cpp |3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

New commits:
commit 9e8ddfc0c1668067219a1debca2aa5cb8f4c72b4
Author: Tor Lillqvist 
AuthorDate: Wed Jul 1 13:48:01 2020 +0300
Commit: Tor Lillqvist 
CommitDate: Wed Jul 1 16:43:56 2020 +0200

Don't call JailUtil::cleanupJails() on MOBILEAPP

Change-Id: I7a01ff9afaccb6e3f4b399a12d828c8d44bcb4c2
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/97612
Tested-by: Jenkins
Reviewed-by: Tor Lillqvist 

diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index a93b41f5f..6efb55655 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -1185,13 +1185,14 @@ void LOOLWSD::initialize(Application& self)
 }
 else
 {
+#if !MOBILEAPP
 if (CleanupOnly)
 {
 // Cleanup and exit.
 JailUtil::cleanupJails(ChildRoot);
 std::exit(EX_OK);
 }
-
+#endif
 if (ChildRoot[ChildRoot.size() - 1] != '/')
 ChildRoot += '/';
 
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2020-07-01 Thread Jan Holesovsky (via logerrit)
 wsd/LOOLWSD.cpp |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit 22e2f50f556a3eb4ee292301c63a30a252c12b07
Author: Jan Holesovsky 
AuthorDate: Wed Jul 1 12:34:36 2020 +0200
Commit: Tor Lillqvist 
CommitDate: Wed Jul 1 16:43:09 2020 +0200

android: Make the documents open again.

The files stopped opening after
5c9988f2e345ca82e7bb5f5e9bf66a30b82a0446, but just avoiding the new
Jails stuff seems enough to fix it.

Change-Id: I4c3be058dd24e9500f64c240571f0e76a17ac8b8
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/97608
Tested-by: Jenkins
Reviewed-by: Tor Lillqvist 

diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index 3d3f2f290..a93b41f5f 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -1205,6 +1205,7 @@ void LOOLWSD::initialize(Application& self)
 LOG_INF("Creating childroot: " + ChildRoot);
 }
 
+#if !MOBILEAPP
 // Setup the jails.
 JailUtil::setupJails(getConfigValue(conf, "mount_jail_tree", true), 
ChildRoot,
  SysTemplate);
@@ -1225,7 +1226,6 @@ void LOOLWSD::initialize(Application& self)
 }
 LOG_INF("NumPreSpawnedChildren set to " << NumPreSpawnedChildren << '.');
 
-#if !MOBILEAPP
 FileUtil::registerFileSystemForDiskSpaceChecks(ChildRoot);
 
 const auto maxConcurrency = getConfigValue(conf, 
"per_document.max_concurrency", 4);
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2020-07-01 Thread Michael Meeks (via logerrit)
 wsd/LOOLWSD.cpp |   31 ++-
 1 file changed, 14 insertions(+), 17 deletions(-)

New commits:
commit d4fa74916c3f18af037e4e36985070badce55456
Author: Michael Meeks 
AuthorDate: Wed Jul 1 12:19:39 2020 +0100
Commit: Michael Meeks 
CommitDate: Wed Jul 1 15:15:19 2020 +0200

Unconditionally display & log version on start & in dumpState.

Hopefully makes our logs generally much more useful.

Change-Id: I6e7a96792e322fc40eb7dda1aa16a2a4ada07df6
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/97615
Tested-by: Jenkins
Tested-by: Michael Meeks 
Reviewed-by: Michael Meeks 

diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index 5d3b17808..3d3f2f290 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -219,10 +219,6 @@ int LOOLWSD::prisonerServerSocketFD;
 
 #else
 
-/// New LOK child processes ready to host documents.
-//TODO: Move to a more sensible namespace.
-static bool DisplayVersion = false;
-
 /// Funky latency simulation basic delay (ms)
 static int SimulatedLatencyMs = 0;
 
@@ -1576,7 +1572,7 @@ void LOOLWSD::handleOption(const std::string& optionName,
 std::exit(EX_OK);
 }
 else if (optionName == "version")
-DisplayVersion = true;
+; // ignore for compatibility
 else if (optionName == "cleanup")
 CleanupOnly = true; // Flag for later as we need the config.
 else if (optionName == "port")
@@ -1836,8 +1832,7 @@ bool LOOLWSD::createForKit()
 if (UnitWSD::get().hasKitHooks())
 args.push_back("--unitlib=" + UnitTestLibrary);
 
-if (DisplayVersion)
-args.push_back("--version");
+args.push_back("--version");
 
 if (NoCapsForKit)
 args.push_back("--nocaps");
@@ -3513,8 +3508,12 @@ public:
 Socket::InhibitThreadChecks = true;
 SocketPoll::InhibitThreadChecks = true;
 
-os << "LOOLWSDServer:"
+std::string version, hash;
+Util::getVersionInfo(version, hash);
+
+os << "LOOLWSDServer: " << version << " - " << hash
 #if !MOBILEAPP
+   << "\n  Kit version: " << LOOLWSD::LOKitVersion
<< "\n  Ports: server " << ClientPortNumber << " prisoner " << 
MasterLocation
<< "\n  SSL: " << (LOOLWSD::isSSLEnabled() ? "https" : "http")
<< "\n  SSL-Termination: " << (LOOLWSD::isSSLTermination() ? "yes" 
: "no")
@@ -3734,19 +3733,17 @@ int LOOLWSD::innerMain()
 SigUtil::setTerminationSignals();
 #endif
 
-#ifdef __linux
+#if !MOBILEAPP
+#  ifdef __linux
 // down-pay all the forkit linking cost once & early.
 setenv("LD_BIND_NOW", "1", 1);
+#  endif
 
-#if !MOBILEAPP
 HostIdentifier = Util::rng::getHexString(8);
-if (DisplayVersion)
-{
-std::string version, hash;
-Util::getVersionInfo(version, hash);
-LOG_INF("Loolwsd version details: " << version << " - " << hash << " - 
id " << HostIdentifier << " - on " << Util::getLinuxVersion());
-}
-#endif
+
+std::string version, hash;
+Util::getVersionInfo(version, hash);
+LOG_INF("Loolwsd version details: " << version << " - " << hash << " - id 
" << HostIdentifier << " - on " << Util::getLinuxVersion());
 #endif
 
 initializeSSL();
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2020-06-24 Thread Tor Lillqvist (via logerrit)
 wsd/LOOLWSD.cpp |5 +
 1 file changed, 5 insertions(+)

New commits:
commit 9077962bfe8466c12bb2475778372c1dc7bf1a0d
Author: Tor Lillqvist 
AuthorDate: Wed Jun 24 13:45:24 2020 +0300
Commit: Tor Lillqvist 
CommitDate: Wed Jun 24 13:16:05 2020 +0200

The locale dance is unnecessary on iOS

The code does not work on iOS as locales apparently are differently
named than on Linux.

Besides, we have been able to open files with arbitrary non-ASCII
names, like 000泌111.odt, just fine for some time already.

Change-Id: I3f4a342721a7ad22786b8bdb1cd9829087539178
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/97020
Tested-by: Jenkins
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Tor Lillqvist 

diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index 96be14b4e..9c713fbde 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -3668,6 +3668,10 @@ int LOOLWSD::innerMain()
 
 initializeSSL();
 
+#ifndef IOS
+// We can open files with non-ASCII names just fine on iOS without this, 
and this code is
+// heavily Linux-specific anyway.
+
 // Force a uniform UTF-8 locale for ourselves & our children.
 char* locale = std::setlocale(LC_ALL, "C.UTF-8");
 if (!locale)
@@ -3683,6 +3687,7 @@ int LOOLWSD::innerMain()
 LOG_INF("Locale is set to " + std::string(locale));
 ::setenv("LC_ALL", locale, 1);
 }
+#endif
 
 #if !MOBILEAPP
 // We use the same option set for both parent and child loolwsd,
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2020-06-22 Thread Tor Lillqvist (via logerrit)
 wsd/LOOLWSD.cpp |3 +++
 1 file changed, 3 insertions(+)

New commits:
commit f0ecb354471ed230abfe4c83af45cf18b817e758
Author: Tor Lillqvist 
AuthorDate: Mon Jun 22 13:34:22 2020 +0300
Commit: Tor Lillqvist 
CommitDate: Mon Jun 22 13:52:47 2020 +0200

Bin spurious misleading output in the MOBILEAPP case

Change-Id: Ia731ac97174aa85842a156753bcd9e8a0fef9718
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/96842
Tested-by: Jenkins CollaboraOffice 
Tested-by: Jenkins
Reviewed-by: Tor Lillqvist 

diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index 9a701f262..587c22160 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -3787,7 +3787,10 @@ int LOOLWSD::innerMain()
 
 /// The main-poll does next to nothing:
 SocketPoll mainWait("main");
+
+#if !MOBILEAPP
 std::cerr << "Ready to accept connections on port " << ClientPortNumber << 
 ".\n" << std::endl;
+#endif
 
 // Reset the child-spawn timeout to the default, now that we're set.
 ChildSpawnTimeoutMs = CHILD_TIMEOUT_MS;
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2020-06-21 Thread Andras Timar (via logerrit)
 wsd/LOOLWSD.cpp |   16 ++--
 1 file changed, 14 insertions(+), 2 deletions(-)

New commits:
commit 3a904c203152636c4f59dc62c792e64389c6abe7
Author: Andras Timar 
AuthorDate: Sun Jun 21 10:49:23 2020 +0200
Commit: Andras Timar 
CommitDate: Sun Jun 21 16:25:50 2020 +0200

fall back to en_US.UTF-8 if C.UTF-8 does not exist

It turned out that C.UTF-8 is not supported on RH7/CentOS7.
We started to use C.UTF-8 because it was widely available and we
could shave off locale data in Ubuntu based docker images and
AppImage. With this patch we fall back en_US.UTF-8 if C.UTF-8 does
not exist and add some logging.

Change-Id: Idea0ae885dc8cdd9ef33279bd90eb882a656d75c
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/96788
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Andras Timar 

diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index 5c77a8a12..9a701f262 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -3669,8 +3669,20 @@ int LOOLWSD::innerMain()
 initializeSSL();
 
 // Force a uniform UTF-8 locale for ourselves & our children.
-::setenv("LC_ALL", "C.UTF-8", 1);
-setlocale(LC_ALL, "C.UTF-8");
+char* locale = std::setlocale(LC_ALL, "C.UTF-8");
+if (!locale)
+{
+// rhbz#1590680 - C.UTF-8 is unsupported on RH7
+LOG_WRN("Could not set locale to C.UTF-8, will try en_US.UTF-8");
+locale = std::setlocale(LC_ALL, "en_US.UTF-8");
+if (!locale)
+LOG_WRN("Could not set locale to en_US.UTF-8. Without UTF-8 
support documents with non-ASCII file names cannot be opened.");
+}
+if (locale)
+{
+LOG_INF("Locale is set to " + std::string(locale));
+::setenv("LC_ALL", locale, 1);
+}
 
 #if !MOBILEAPP
 // We use the same option set for both parent and child loolwsd,
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2020-06-18 Thread Aron Budea (via logerrit)
 wsd/LOOLWSD.cpp |   11 +++
 1 file changed, 7 insertions(+), 4 deletions(-)

New commits:
commit 4e2e2f22c6f199e2afda4d9509b7795a2f4d7c09
Author: Aron Budea 
AuthorDate: Thu Jun 18 07:27:08 2020 +0200
Commit: Michael Meeks 
CommitDate: Thu Jun 18 11:43:57 2020 +0200

wsd: Don't try to resolve an accepted IP address

...and pollute the logs with warnings if it fails.

Change-Id: I71828205b8d020287f5b6d0bb82feb17c2fdd2f7
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/96567
Tested-by: Jenkins
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Michael Meeks 

diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index c77c49152..5c77a8a12 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -2211,14 +2211,17 @@ public:
 addressToCheck = Util::trim(param);
 try
 {
-hostToCheck = 
Poco::Net::DNS::resolve(addressToCheck).name();
-allow &= allowPostFrom(addressToCheck) || 
StorageBase::allowedWopiHost(hostToCheck);
+if (!allowPostFrom(addressToCheck))
+{
+hostToCheck = 
Poco::Net::DNS::resolve(addressToCheck).name();
+allow &= StorageBase::allowedWopiHost(hostToCheck);
+}
 }
 catch (const Poco::Exception& exc)
 {
 LOG_WRN("Poco::Net::DNS::resolve(\"" << addressToCheck << 
"\") failed: " << exc.displayText());
-// We can't find out the hostname, check the IP only
-allow &= allowPostFrom(addressToCheck);
+// We can't find out the hostname, and it already failed 
the IP check
+allow = false;
 }
 if(!allow)
 {
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2020-06-08 Thread Michael Meeks (via logerrit)
 wsd/LOOLWSD.cpp |   15 +++
 1 file changed, 15 insertions(+)

New commits:
commit 848bacaa7f9bd7e55b4c088059cc9d0799fa2bdc
Author: Michael Meeks 
AuthorDate: Mon Jun 8 14:43:04 2020 +0100
Commit: Michael Meeks 
CommitDate: Mon Jun 8 16:06:57 2020 +0200

Proxy: shutdown socket with error if we can't find documentbroker.

Also called if/as/when the document is unloading as you connect.

Change-Id: I494dc207219298e07fba664cd2cbdd5d5b8ac889
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/95809
Tested-by: Jenkins
Reviewed-by: Michael Meeks 

diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index f2c01965e..457e109b5 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -3016,6 +3016,21 @@ private:
 });
 });
 }
+else
+{
+auto streamSocket = 
std::static_pointer_cast(disposition.getSocket());
+LOG_ERR("Failed to find document");
+// badness occurred:
+std::ostringstream oss;
+oss << "HTTP/1.1 400\r\n"
+<< "Date: " << Util::getHttpTimeNow() << "\r\n"
+<< "User-Agent: LOOLWSD WOPI Agent\r\n"
+<< "Content-Length: \r\n"
+<< "\r\n";
+// FIXME: send docunloading & re-try on client ?
+streamSocket->send(oss.str());
+streamSocket->shutdown();
+}
 }
 
 void handleClientWsUpgrade(const Poco::Net::HTTPRequest& request,
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2020-06-08 Thread Jan Holesovsky (via logerrit)
 wsd/LOOLWSD.cpp |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit 1bcaac7a6ea2f5f61071eb8ed11d4c6144e70c21
Author: Jan Holesovsky 
AuthorDate: Fri Jun 5 21:36:24 2020 +0200
Commit: Jan Holesovsky 
CommitDate: Mon Jun 8 11:35:58 2020 +0200

One more check that should be overriden with --disable-lool-user-checking.

Change-Id: I3f0170775abad34b2b9de2078410d00d46853ad9
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/95619
Tested-by: Jenkins
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Jan Holesovsky 

diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index 39365cbe7..f2c01965e 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -852,7 +852,7 @@ LOOLWSD::~LOOLWSD()
 void LOOLWSD::initialize(Application& self)
 {
 #if !MOBILEAPP
-if (geteuid() == 0)
+if (geteuid() == 0 && CheckLoolUser)
 {
 throw std::runtime_error("Do not run as root. Please run as lool 
user.");
 }
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2020-06-03 Thread Michael Meeks (via logerrit)
 wsd/LOOLWSD.cpp |   29 -
 1 file changed, 28 insertions(+), 1 deletion(-)

New commits:
commit affa943e4b3d508ca9feba32481e4b418dcf19d9
Author: Michael Meeks 
AuthorDate: Wed Jun 3 17:13:40 2020 +0100
Commit: Michael Meeks 
CommitDate: Wed Jun 3 18:59:20 2020 +0200

dumpState should dump much more loolwsd state.

Change-Id: I0e59d56b2b735aea013a59850ff3f37fd72bc8b9
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/95447
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Michael Meeks 

diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index c672932f0..39365cbe7 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -734,6 +734,8 @@ std::string LOOLWSD::OverrideWatermark;
 std::set 
LOOLWSD::PluginConfigurations;
 std::chrono::time_point LOOLWSD::StartTime;
 
+// If you add global state please update dumpState below too
+
 static std::string UnitTestLibrary;
 
 unsigned int LOOLWSD::NumPreSpawnedChildren = 0;
@@ -3402,12 +3404,37 @@ public:
<< "\n  SSL-Termination: " << (LOOLWSD::isSSLTermination() ? "yes" 
: "no")
<< "\n  Security " << (LOOLWSD::NoCapsForKit ? "no" : "") << " 
chroot, "
<< (LOOLWSD::NoSeccomp ? "no" : "") << " api lockdown"
+   << "\n  Admin: " << (LOOLWSD::AdminEnabled ? "enabled" : "disabled")
 #endif
<< "\n  TerminationFlag: " << SigUtil::getTerminationFlag()
<< "\n  isShuttingDown: " << SigUtil::getShutdownRequestFlag()
<< "\n  NewChildren: " << NewChildren.size()
<< "\n  OutstandingForks: " << OutstandingForks
-   << "\n  NumPreSpawnedChildren: " << LOOLWSD::NumPreSpawnedChildren;
+   << "\n  NumPreSpawnedChildren: " << LOOLWSD::NumPreSpawnedChildren
+   << "\n  ChildSpawnTimeoutMs: " << ChildSpawnTimeoutMs
+   << "\n  Document Brokers: " << DocBrokers.size()
+#if !MOBILEAPP
+   << "\n  of which ConvertTo: " << ConvertToBroker::getInstanceCount()
+#endif
+   << "\n  vs. MaxDocuments: " << LOOLWSD::MaxDocuments
+   << "\n  NumConnections: " << LOOLWSD::NumConnections
+   << "\n  vs. MaxConnections: " << LOOLWSD::MaxConnections
+   << "\n  SysTemplate: " << LOOLWSD::SysTemplate
+   << "\n  LoTemplate: " << LOOLWSD::LoTemplate
+   << "\n  ChildRoot: " << LOOLWSD::ChildRoot
+   << "\n  FileServerRoot: " << LOOLWSD::FileServerRoot
+   << "\n  WelcomeFilesRoot: " << LOOLWSD::WelcomeFilesRoot
+   << "\n  ServiceRoot: " << LOOLWSD::ServiceRoot
+   << "\n  LOKitVersion: " << LOOLWSD::LOKitVersion
+   << "\n  HostIdentifier: " << LOOLWSD::HostIdentifier
+   << "\n  ConfigFile: " << LOOLWSD::ConfigFile
+   << "\n  ConfigDir: " << LOOLWSD::ConfigDir
+   << "\n  LogLevel: " << LOOLWSD::LogLevel
+   << "\n  AnonymizeUserData: " << (LOOLWSD::AnonymizeUserData ? "yes" 
: "no")
+   << "\n  CheckLoolUser: " << (LOOLWSD::CheckLoolUser ? "yes" : "no")
+   << "\n  IsProxyPrefixEnabled: " << (LOOLWSD::IsProxyPrefixEnabled ? 
"yes" : "no")
+   << "\n  OverrideWatermark: " << LOOLWSD::OverrideWatermark
+;
 
 os << "\nServer poll:\n";
 _acceptPoll.dumpState(os);
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2020-06-02 Thread Ashod Nakashian (via logerrit)
 wsd/LOOLWSD.cpp|6 +++---
 wsd/RequestDetails.hpp |2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)

New commits:
commit dd93a7eeb457774d89aab73507bfb4ef1dd86015
Author: Ashod Nakashian 
AuthorDate: Sun May 24 08:37:18 2020 -0400
Commit: Ashod Nakashian 
CommitDate: Tue Jun 2 17:26:59 2020 +0200

wsd: reuse more code and reduce inefficiencies

Change-Id: I8cf4709822750bce92ceab3fbac50240035776fa
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/95289
Tested-by: Jenkins CollaboraOffice 
Tested-by: Jenkins
Reviewed-by: Ashod Nakashian 

diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index bb5aa4aa4..6802a1c28 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -2357,10 +2357,10 @@ private:
 });
 }
 else if (requestDetails.isGetOrHead("/"))
-handleRootRequest(request, socket);
+handleRootRequest(requestDetails, socket);
 
 else if (requestDetails.isGet("/favicon.ico"))
-handleFaviconRequest(request, socket);
+handleFaviconRequest(requestDetails, socket);
 
 else if (requestDetails.isGet("/hosting/discovery") ||
  requestDetails.isGet("/hosting/discovery/"))
@@ -3054,7 +3054,7 @@ private:
 LOG_INF("Starting GET request handler for session [" << _id << "] 
on url [" << LOOLWSD::anonymizeUrl(url) << "].");
 
 // Indicate to the client that document broker is searching.
-const std::string status("statusindicator: find");
+static const std::string status("statusindicator: find");
 LOG_TRC("Sending to Client [" << status << "].");
 ws->sendMessage(status);
 
diff --git a/wsd/RequestDetails.hpp b/wsd/RequestDetails.hpp
index 58e33d76d..89c36654e 100644
--- a/wsd/RequestDetails.hpp
+++ b/wsd/RequestDetails.hpp
@@ -66,7 +66,7 @@ public:
 }
 bool startsWith(const char *path)
 {
-return !strncmp(_uriString.c_str(), path, strlen(path));
+return Util::startsWith(_uriString, path);
 }
 bool equals(size_t index, const char *string) const
 {
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2020-05-28 Thread Andras Timar (via logerrit)
 wsd/LOOLWSD.cpp |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

New commits:
commit 15ced64d323e10660e60abbbcfa7386780dcfb4e
Author: Andras Timar 
AuthorDate: Thu May 28 11:04:29 2020 +0200
Commit: Jan Holesovsky 
CommitDate: Thu May 28 13:18:12 2020 +0200

use C.UTF-8 locale rather than en_US.UTF-8

because en_US.UTF-8 is not present in minimal
environments such as docker images

Change-Id: I9edcb44df8a8f33117b2c5f1d2fa9e330bfc1770
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/95018
Tested-by: Jenkins
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Jan Holesovsky 

diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index 57b7c926f..e016bd01b 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -3609,8 +3609,8 @@ int LOOLWSD::innerMain()
 initializeSSL();
 
 // Force a uniform UTF-8 locale for ourselves & our children.
-::setenv("LC_ALL", "en_US.UTF-8", 1);
-setlocale(LC_ALL, "en_US.UTF-8");
+::setenv("LC_ALL", "C.UTF-8", 1);
+setlocale(LC_ALL, "C.UTF-8");
 
 #if !MOBILEAPP
 // We use the same option set for both parent and child loolwsd,
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2020-05-27 Thread Ashod Nakashian (via logerrit)
 wsd/LOOLWSD.cpp |   19 ++-
 1 file changed, 18 insertions(+), 1 deletion(-)

New commits:
commit 4d0ae969e12225fe875270b8fb2d3b0e08e35e44
Author: Ashod Nakashian 
AuthorDate: Tue May 26 15:12:13 2020 -0400
Commit: Jan Holesovsky 
CommitDate: Wed May 27 12:56:02 2020 +0200

wsd: expose version-hash programmatically

Passing --version-hash to loolwsd now prints the
hash and exits. This is designed to be used with
proxy.php to check the version running.

Also, include the version and hash in the
hosting/capabilities JSON response.

Note that --version still prints/logs the version
and doesn't exit. It seems that is designed to
log it before running, and so it might be used
in the wild. Changing the behavior in minor upgrade
might break some production servers that have
--version added to their execution command-line.

Change-Id: I30e6945f797a902ed4b3aae6f5f1b8518000946b
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/94911
Tested-by: Jenkins
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Jan Holesovsky 

diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index a5212dffc..57b7c926f 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -1407,7 +1407,11 @@ void LOOLWSD::defineOptions(OptionSet& optionSet)
 .required(false)
 .repeatable(false));
 
-optionSet.addOption(Option("version", "", "Display version information.")
+optionSet.addOption(Option("version-hash", "", "Display product 
version-hash information.")
+.required(false)
+.repeatable(false));
+
+optionSet.addOption(Option("version", "", "Display version and hash 
information.")
 .required(false)
 .repeatable(false));
 
@@ -1484,6 +1488,13 @@ void LOOLWSD::handleOption(const std::string& optionName,
 displayHelp();
 std::exit(EX_OK);
 }
+else if (optionName == "version-hash")
+{
+std::string version, hash;
+Util::getVersionInfo(version, hash);
+std::cout << hash << std::endl;
+std::exit(EX_OK);
+}
 else if (optionName == "version")
 DisplayVersion = true;
 else if (optionName == "port")
@@ -3250,6 +3261,12 @@ private:
 // Set the product name
 capabilities->set("productName", APP_NAME);
 
+// Set the product version
+capabilities->set("productVersion", LOOLWSD_VERSION);
+
+// Set the product version hash
+capabilities->set("productVersionHash", LOOLWSD_VERSION_HASH);
+
 // Set that this is a proxy.php-enabled instance
 capabilities->set("hasProxyPrefix", LOOLWSD::IsProxyPrefixEnabled);
 
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2020-05-25 Thread Michael Meeks (via logerrit)
 wsd/LOOLWSD.cpp |   11 +++
 1 file changed, 11 insertions(+)

New commits:
commit dac51dbcbd803a78b76537e491c97d7d7b209e10
Author: Michael Meeks 
AuthorDate: Mon May 25 20:25:25 2020 +0100
Commit: Michael Meeks 
CommitDate: Mon May 25 21:53:56 2020 +0200

Sample for debugging a specific protocol command.

Change-Id: I662c9edb10d1ebbb729cc4c9bc053dc113cb027e
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/94807
Tested-by: Michael Meeks 
Reviewed-by: Michael Meeks 

diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index aa3a6be1d..a5212dffc 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -2238,6 +2238,17 @@ private:
 
 Poco::MemoryInputStream startmessage(>getInBuffer()[0],
  socket->getInBuffer().size());;
+
+#if 0 // debug a specific command's payload
+if (Util::findInVector(socket->getInBuffer(), "insertfile") != 
std::string::npos)
+{
+std::ostringstream oss;
+oss << "Debug - specific command:\n";
+socket->dumpState(oss);
+LOG_INF(oss.str());
+}
+#endif
+
 Poco::Net::HTTPRequest request;
 
 StreamSocket::MessageMap map;
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2020-05-25 Thread Michael Meeks (via logerrit)
 wsd/LOOLWSD.cpp |1 +
 1 file changed, 1 insertion(+)

New commits:
commit 54ed949a20a8c10f8a03acc3939be1bc5f2700f7
Author: Michael Meeks 
AuthorDate: Mon May 25 16:33:25 2020 +0100
Commit: Michael Meeks 
CommitDate: Mon May 25 17:53:54 2020 +0200

insertfile - close socket after inserting.

Can fix hangs on insertion where the read side of the socket is
done sending, but not yet closed.

Change-Id: Ib2e943699e54a3d566434a46200402b8ec4937e0
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/94798
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Michael Meeks 

diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index c7ff6572f..aa3a6be1d 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -2813,6 +2813,7 @@ private:
 handler.takeFile();
 response.setContentLength(0);
 socket->send(response);
+socket->shutdown();
 return;
 }
 }
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2020-05-25 Thread Michael Meeks (via logerrit)
 wsd/LOOLWSD.cpp |1 +
 1 file changed, 1 insertion(+)

New commits:
commit bb4250ea51776dc5fdd8e18733b6c1435e157fc1
Author: Michael Meeks 
AuthorDate: Mon May 25 16:21:13 2020 +0100
Commit: Michael Meeks 
CommitDate: Mon May 25 17:50:38 2020 +0200

Avoid erroneous logging on insertfile.

Change-Id: Id5c658013d4907da3185e4c049e10a698bcfdc51
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/94797
Tested-by: Jenkins
Reviewed-by: Michael Meeks 

diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index ca1f437b4..c7ff6572f 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -2810,6 +2810,7 @@ private:
 LOG_INF("Perform insertfile: " << formChildid << ", " << 
formName << ", filename: " << fileName);
 File(dirPath).createDirectories();
 File(handler.getFilename()).moveTo(fileName);
+handler.takeFile();
 response.setContentLength(0);
 socket->send(response);
 return;
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2020-05-25 Thread Jan Holesovsky (via logerrit)
 wsd/LOOLWSD.cpp |3 +++
 1 file changed, 3 insertions(+)

New commits:
commit cecf3922cb4c5270659b887fb22abce5f6c8b839
Author: Jan Holesovsky 
AuthorDate: Mon May 25 14:46:31 2020 +0200
Commit: Jan Holesovsky 
CommitDate: Mon May 25 15:35:54 2020 +0200

Adventise the proxy prefix support in /hosting/capabilities.

Change-Id: I09e340b1ecb1580feffe66c53b79d91749f0f9af
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/94790
Tested-by: Jenkins CollaboraOffice 
Tested-by: Jenkins
Reviewed-by: Jan Holesovsky 

diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index 8c1f6b945..ca1f437b4 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -3237,6 +3237,9 @@ private:
 // Set the product name
 capabilities->set("productName", APP_NAME);
 
+// Set that this is a proxy.php-enabled instance
+capabilities->set("hasProxyPrefix", LOOLWSD::IsProxyPrefixEnabled);
+
 std::ostringstream ostrJSON;
 capabilities->stringify(ostrJSON);
 return ostrJSON.str();
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2020-05-25 Thread Jan Holesovsky (via logerrit)
 wsd/LOOLWSD.cpp |2 --
 1 file changed, 2 deletions(-)

New commits:
commit c6598299819654c01678e2a26753bbe9f82a59d7
Author: Jan Holesovsky 
AuthorDate: Fri May 22 17:57:54 2020 +0200
Commit: Jan Holesovsky 
CommitDate: Mon May 25 15:29:52 2020 +0200

Actually inform about the accepting connections to the console.

We already write there other startup information, and this is important
to know too :-)

Change-Id: I6cddcdc7690b9019a5dcf7351f60f3e769878e07
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/94698
Reviewed-by: Jan Holesovsky 
Tested-by: Jenkins
Tested-by: Jenkins CollaboraOffice 

diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index b03574724..8c1f6b945 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -3682,9 +3682,7 @@ int LOOLWSD::innerMain()
 
 /// The main-poll does next to nothing:
 SocketPoll mainWait("main");
-#if ENABLE_DEBUG
 std::cerr << "Ready to accept connections on port " << ClientPortNumber << 
 ".\n" << std::endl;
-#endif
 
 // Reset the child-spawn timeout to the default, now that we're set.
 ChildSpawnTimeoutMs = CHILD_TIMEOUT_MS;
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2020-04-30 Thread Jan Holesovsky (via logerrit)
 wsd/LOOLWSD.cpp |   10 --
 1 file changed, 8 insertions(+), 2 deletions(-)

New commits:
commit 4669934a263b40512988626b8f251264cb6f6d69
Author: Jan Holesovsky 
AuthorDate: Thu Apr 30 10:34:23 2020 +0200
Commit: Jan Holesovsky 
CommitDate: Thu Apr 30 15:00:58 2020 +0200

Allow overriding the lo-template-path with a command line switch.

This was completely removed in commit
db176ee45baae93ab4411c23d32ae1d0f608352b from good reasons - it is
really bad to have that in the config file, the Online and Core versions
are tightly coupled.

Having said that, the possibility to override still has its use cases,
so let's introduce a command line switch for those who need it & know
what they are doing.

Change-Id: I76875f7c7a174fbc16985299eb968a41814b7962
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/93196
Reviewed-by: Andras Timar 
Tested-by: Jan Holesovsky 

diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index 6ef3f2c84..f4812ff30 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -715,7 +715,7 @@ bool LOOLWSD::DummyLOK = false;
 std::string LOOLWSD::FuzzFileName;
 #endif
 std::string LOOLWSD::SysTemplate;
-std::string LOOLWSD::LoTemplate;
+std::string LOOLWSD::LoTemplate = LO_PATH;
 std::string LOOLWSD::ChildRoot;
 std::string LOOLWSD::ServerName;
 std::string LOOLWSD::FileServerRoot;
@@ -1145,7 +1145,6 @@ void LOOLWSD::initialize(Application& self)
 #endif
 
 SysTemplate = getPathFromConfig("sys_template_path");
-LoTemplate = LO_PATH;
 ChildRoot = getPathFromConfig("child_root_path");
 ServerName = config().getString("server_name");
 
@@ -1441,6 +1440,11 @@ void LOOLWSD::defineOptions(OptionSet& optionSet)
 .repeatable(false)
 .argument("path"));
 
+optionSet.addOption(Option("lo-template-path", "", "Override the LOK core 
installation directory path.")
+.required(false)
+.repeatable(false)
+.argument("path"));
+
 #if ENABLE_DEBUG
 optionSet.addOption(Option("unitlib", "", "Unit testing library path.")
 .required(false)
@@ -1499,6 +1503,8 @@ void LOOLWSD::handleOption(const std::string& optionName,
 ConfigFile = value;
 else if (optionName == "config-dir")
 ConfigDir = value;
+else if (optionName == "lo-template-path")
+LoTemplate = value;
 #if ENABLE_DEBUG
 else if (optionName == "unitlib")
 UnitTestLibrary = value;
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2020-04-24 Thread Michael Meeks (via logerrit)
 wsd/LOOLWSD.cpp |   31 +--
 1 file changed, 17 insertions(+), 14 deletions(-)

New commits:
commit 840fb7c4bd0c6d4cd4c2937f8830a60e29c92aef
Author: Michael Meeks 
AuthorDate: Thu Apr 23 13:39:33 2020 +0100
Commit: Jan Holesovsky 
CommitDate: Fri Apr 24 20:58:20 2020 +0200

Proof: inject ProxyPrefix into discovery xml.

Change-Id: Ief79372d17e830c10883805e430a8b8cfb6d4f31
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/92821
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Jan Holesovsky 

diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index 856eaa345..c34c2c315 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -2485,8 +2485,17 @@ private:
 LOG_DBG("Wopi discovery request: " << request.getURI());
 
 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);
+std::string srvUrl =
+#if ENABLE_SSL
+((LOOLWSD::isSSLEnabled() || LOOLWSD::isSSLTermination()) ? 
"https://; : "http://;)
+#else
+"http://;
+#endif
++ (LOOLWSD::ServerName.empty() ? request.getHost() : 
LOOLWSD::ServerName)
++ LOOLWSD::ServiceRoot;
+if (request.has("ProxyPrefix"))
+srvUrl += request["ProxyPrefix"];
+Poco::replaceInPlace(xml, std::string("%SRV_URI%"), srvUrl);
 
 // TODO: Refactor this to some common handler.
 std::ostringstream oss;
@@ -3169,20 +3178,14 @@ private:
 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 rootUriValue =
-#if ENABLE_SSL
-((LOOLWSD::isSSLEnabled() || LOOLWSD::isSSLTermination()) ? 
"https://; : "http://;)
-#else
-"http://;
-#endif
-+ std::string("%SERVER_HOST%")
-+ LOOLWSD::ServiceRoot;
-const std::string uriValue = rootUriValue
-   + "/loleaflet/" LOOLWSD_VERSION_HASH "/" + 
loleafletHtml + '?';
+
+const std::string action = "action";
+const std::string urlsrc = "urlsrc";
+
+const std::string rootUriValue = "%SRV_URI%";
+const std::string uriValue = rootUriValue + "/loleaflet/" 
LOOLWSD_VERSION_HASH "/" + loleafletHtml + '?';
 
 InputSource inputSrc(discoveryPath);
 DOMParser parser;
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2020-04-24 Thread Michael Meeks (via logerrit)
 wsd/LOOLWSD.cpp |3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

New commits:
commit 2bd440f2800187cea6b04058ec07e615ed71a19e
Author: Michael Meeks 
AuthorDate: Wed Apr 22 21:07:10 2020 +0100
Commit: Jan Holesovsky 
CommitDate: Fri Apr 24 20:57:49 2020 +0200

Proxy: detect isWaiting properly now we have requests serials.

Change-Id: I76b2602192f1a49df73f4354bb26209fe2ed6d5d
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/92820
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Jan Holesovsky 

diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index 38496b184..856eaa345 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -2944,8 +2944,7 @@ private:
 
 std::string fullURL = request.getURI();
 std::string ending = "/ws/wait";
-bool isWaiting = (fullURL.size() > ending.size() &&
-  std::equal(ending.rbegin(), ending.rend(), 
fullURL.rbegin()));
+bool isWaiting = fullURL.find(ending) != std::string::npos;
 if (docBroker)
 {
 // need to move into the DocumentBroker context before doing 
session lookup / creation etc.
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2020-04-20 Thread Tor Lillqvist (via logerrit)
 wsd/LOOLWSD.cpp |   10 +++---
 wsd/LOOLWSD.hpp |6 +-
 2 files changed, 12 insertions(+), 4 deletions(-)

New commits:
commit 6b8456679f10afc01fa92726bb1b5caa211385d0
Author: Tor Lillqvist 
AuthorDate: Mon Apr 20 11:47:50 2020 +0300
Commit: Tor Lillqvist 
CommitDate: Mon Apr 20 11:17:29 2020 +0200

Surround some code that is unused in the mobile apps with #if !MOBILEAPP

Reduces the risk of starting to look into something that is actually
never used in the mobile apps, when your intent is to re-work
soemthing for the mobile apps.

Change-Id: I04c562758a1b336690c7adbfd32b260cf26d9f87
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/92554
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Tor Lillqvist 

diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index 9ab86355a..d54788d49 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -696,11 +696,11 @@ inline std::string getServiceURI(const std::string , 
bool asAdmin = false)
 
 std::atomic LOOLWSD::NextConnectionId(1);
 
+#if !MOBILEAPP
 #ifndef KIT_IN_PROCESS
 std::atomic LOOLWSD::ForKitProcId(-1);
 std::shared_ptr LOOLWSD::ForKitProc;
 #endif
-#if !MOBILEAPP
 bool LOOLWSD::NoCapsForKit = false;
 bool LOOLWSD::NoSeccomp = false;
 bool LOOLWSD::AdminEnabled = true;
@@ -755,6 +755,7 @@ public:
 /// Check prisoners are still alive and balanced.
 void wakeupHook() override;
 
+#if !MOBILEAPP
 // Resets the forkit porcess object
 void setForKitProcess(const std::weak_ptr& forKitProc)
 {
@@ -790,6 +791,7 @@ public:
 
 private:
 std::weak_ptr _forKitProc;
+#endif
 };
 
 /// This thread listens for and accepts prisoner kit processes.
@@ -809,6 +811,8 @@ public:
 }
 };
 
+#if !MOBILEAPP
+
 void ForKitProcWSHandler::handleMessage(const std::vector )
 {
 LOG_TRC("ForKitProcWSHandler: handling incoming [" << 
LOOLProtocol::getAbbreviatedMessage([0], data.size()) << "].");
@@ -820,9 +824,7 @@ void ForKitProcWSHandler::handleMessage(const 
std::vector )
 int count = std::stoi(tokens[1]);
 if (count >= 0)
 {
-#if !MOBILEAPP
 Admin::instance().addSegFaultCount(count);
-#endif
 LOG_INF(count << " loolkit processes crashed with segmentation 
fault.");
 }
 else
@@ -836,6 +838,8 @@ void ForKitProcWSHandler::handleMessage(const 
std::vector )
 }
 }
 
+#endif
+
 LOOLWSD::LOOLWSD()
 {
 }
diff --git a/wsd/LOOLWSD.hpp b/wsd/LOOLWSD.hpp
index c391cc055..ea3f33f3d 100644
--- a/wsd/LOOLWSD.hpp
+++ b/wsd/LOOLWSD.hpp
@@ -181,6 +181,8 @@ public:
 std::shared_ptr _socket;
 };
 
+#if !MOBILEAPP
+
 class ForKitProcWSHandler: public WebSocketHandler
 {
 public:
@@ -203,6 +205,8 @@ public:
 }
 };
 
+#endif
+
 /// The Server class which is responsible for all
 /// external interactions.
 class LOOLWSD : public Poco::Util::ServerApplication
@@ -221,10 +225,10 @@ public:
 static bool AdminEnabled;
 #if ENABLE_DEBUG
 static bool SingleKit;
-#endif
 #endif
 static std::shared_ptr ForKitProc;
 static std::atomic ForKitProcId;
+#endif
 static bool DummyLOK;
 static std::string FuzzFileName;
 static std::string ConfigFile;
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2020-04-17 Thread Miklos Vajna (via logerrit)
 wsd/LOOLWSD.cpp |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

New commits:
commit ee1d96fd053afb6135d04af0571c7f093c509ca3
Author: Miklos Vajna 
AuthorDate: Fri Apr 17 10:52:06 2020 +0200
Commit: Miklos Vajna 
CommitDate: Fri Apr 17 11:33:47 2020 +0200

wsd: 360 * 1000 would not fit into an int

Change-Id: Ib1ada4e2c51d1eff846130669255582e2cef097d
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/92406
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Miklos Vajna 

diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index 0796b53dd..9ab86355a 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -3564,8 +3564,8 @@ int LOOLWSD::innerMain()
 UnitWSD::get().invokeTest();
 
 // This timeout affects the recovery time of prespawned children.
-const int waitMicroS = UnitWSD::isUnitTesting() ?
-UnitWSD::get().getTimeoutMilliSeconds() * 1000 / 4 :
+const long waitMicroS = UnitWSD::isUnitTesting() ?
+static_cast(UnitWSD::get().getTimeoutMilliSeconds()) * 1000 
/ 4 :
 SocketPoll::DefaultPollTimeoutMicroS * 4;
 mainWait.poll(waitMicroS);
 
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2020-04-13 Thread gokaysatir (via logerrit)
 wsd/LOOLWSD.cpp |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit 4bc3a13ba5c27026ea5625c45b2a8ae496efa7cd
Author: gokaysatir 
AuthorDate: Sun Apr 12 22:36:11 2020 +0300
Commit: Michael Meeks 
CommitDate: Mon Apr 13 17:26:18 2020 +0200

print the OS version in the startup string

Change-Id: Ief7d99b4d4db4f237fb48bbafbac20a989a001bf
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/92091
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Michael Meeks 

diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index dd1be52ba..7f67f2b10 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -3426,7 +3426,7 @@ int LOOLWSD::innerMain()
 {
 std::string version, hash;
 Util::getVersionInfo(version, hash);
-LOG_INF("Loolwsd version details: " << version << " - " << hash << " - 
id " << HostIdentifier);
+LOG_INF("Loolwsd version details: " << version << " - " << hash << " - 
id " << HostIdentifier << " - on " << Util::getLinuxVersion());
 }
 #endif
 #endif
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2020-03-24 Thread Michael Meeks (via logerrit)
 wsd/LOOLWSD.cpp |   19 +--
 1 file changed, 17 insertions(+), 2 deletions(-)

New commits:
commit eb8a9f9b832b45b1a2800b54e94070ac5e739892
Author: Michael Meeks 
AuthorDate: Mon Mar 23 21:08:00 2020 +
Commit: Michael Meeks 
CommitDate: Tue Mar 24 11:13:46 2020 +0100

Use random sub-jail paths when unit testing.

Potentially cleaning up jails used by other WSD's breaks parallel
unit testing quite badly.

Change-Id: I159b87cc36648beb40eea0e363f924eefdf6ebca
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/90942
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Michael Meeks 

diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index aa6b9766b..9c040a8fd 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -3391,8 +3391,18 @@ int LOOLWSD::innerMain()
 LOG_FTL("Missing --childroot option");
 throw MissingOptionException("childroot");
 }
-else if (ChildRoot[ChildRoot.size() - 1] != '/')
-ChildRoot += '/';
+else
+{
+if (ChildRoot[ChildRoot.size() - 1] != '/')
+ChildRoot += '/';
+
+// create a custom sub-path for parallelized unit tests.
+if (UnitBase::isUnitTesting())
+{
+ChildRoot += Util::rng::getHardRandomHexString(8) + "/";
+LOG_TRC("Creating sub-childroot: of " + ChildRoot);
+}
+}
 
 FileUtil::registerFileSystemForDiskSpaceChecks(ChildRoot);
 
@@ -3602,6 +3612,11 @@ int LOOLWSD::innerMain()
 LOG_INF("Removing jail [" << path << "].");
 FileUtil::removeFile(path, true);
 }
+if (UnitBase::isUnitTesting())
+{
+LOG_TRC("Removing sub-childroot: of " + ChildRoot);
+FileUtil::removeFile(ChildRoot, true);
+}
 #endif // !MOBILEAPP
 
 return EX_OK;
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2020-03-20 Thread Miklos Vajna (via logerrit)
 wsd/LOOLWSD.cpp |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit d26aa30cab3335df110110d86fa42750529e9b98
Author: Miklos Vajna 
AuthorDate: Fri Mar 20 18:04:29 2020 +0100
Commit: Andras Timar 
CommitDate: Fri Mar 20 22:05:14 2020 +0100

Fix --with-support-public-key=... build

Change-Id: I4a1ecc16d7b862dae61c80d98d07c0e105c13819
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/90829
Tested-by: Andras Timar 
Reviewed-by: Andras Timar 

diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index 177360dbc..aa6b9766b 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -244,7 +244,7 @@ inline void shutdownLimitReached(const 
std::shared_ptr
 try
 {
 // Let the client know we are shutting down.
-proto->sendTextMessage(error);
+proto->sendTextMessage(error.data(), error.size());
 
 // Shutdown.
 proto->shutdown(true, error);
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2020-03-16 Thread Michael Meeks (via logerrit)
 wsd/LOOLWSD.cpp |   58 
 wsd/LOOLWSD.hpp |4 +++
 2 files changed, 33 insertions(+), 29 deletions(-)

New commits:
commit 4d9d769d950e6555de4392fb10c82efa53002611
Author: Michael Meeks 
AuthorDate: Mon Mar 16 16:19:37 2020 +
Commit: Michael Meeks 
CommitDate: Mon Mar 16 19:36:42 2020 +0100

Expose disk space and session checks via LOOLWSD class.

Change-Id: I7b135d325147694cc33946b34a29ab96b2e2b918
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/90577
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Michael Meeks 

diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index ecceaca34..177360dbc 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -256,8 +256,31 @@ inline void shutdownLimitReached(const 
std::shared_ptr
 }
 #endif
 
-inline void checkSessionLimitsAndWarnClients()
+#if !MOBILEAPP
+/// Internal implementation to alert all clients
+/// connected to any document.
+void alertAllUsersInternal(const std::string& msg)
+{
+std::lock_guard docBrokersLock(DocBrokersMutex);
+
+LOG_INF("Alerting all users: [" << msg << "]");
+
+if (UnitWSD::get().filterAlertAllusers(msg))
+return;
+
+for (auto& brokerIt : DocBrokers)
+{
+std::shared_ptr docBroker = brokerIt.second;
+docBroker->addCallback([msg, docBroker](){ 
docBroker->alertAllUsers(msg); });
+}
+}
+#endif
+
+} // end anonymous namespace
+
+void LOOLWSD::checkSessionLimitsAndWarnClients()
 {
+#if !ENABLE_SUPPORT_KEY
 #if !MOBILEAPP
 ssize_t docBrokerCount = DocBrokers.size() - 
ConvertToBroker::getInstanceCount();
 if (LOOLWSD::MaxDocuments < 1 &&
@@ -276,29 +299,10 @@ inline void checkSessionLimitsAndWarnClients()
 }
 }
 #endif
-}
-
-#if !MOBILEAPP
-/// Internal implementation to alert all clients
-/// connected to any document.
-void alertAllUsersInternal(const std::string& msg)
-{
-std::lock_guard docBrokersLock(DocBrokersMutex);
-
-LOG_INF("Alerting all users: [" << msg << "]");
-
-if (UnitWSD::get().filterAlertAllusers(msg))
-return;
-
-for (auto& brokerIt : DocBrokers)
-{
-std::shared_ptr docBroker = brokerIt.second;
-docBroker->addCallback([msg, docBroker](){ 
docBroker->alertAllUsers(msg); });
-}
-}
 #endif
+}
 
-static void checkDiskSpaceAndWarnClients(const bool cacheLastCheck)
+void LOOLWSD::checkDiskSpaceAndWarnClients(const bool cacheLastCheck)
 {
 #if !MOBILEAPP
 try
@@ -317,8 +321,6 @@ static void checkDiskSpaceAndWarnClients(const bool 
cacheLastCheck)
 #endif
 }
 
-}
-
 /// Remove dead and idle DocBrokers.
 /// The client of idle document should've greyed-out long ago.
 /// Returns true if at least one is removed.
@@ -378,7 +380,7 @@ static int forkChildren(const int number)
 
 if (number > 0)
 {
-checkDiskSpaceAndWarnClients(false);
+LOOLWSD::checkDiskSpaceAndWarnClients(false);
 
 #ifdef KIT_IN_PROCESS
 forkLibreOfficeKit(LOOLWSD::ChildRoot, LOOLWSD::SysTemplate, 
LOOLWSD::LoTemplate, LO_JAIL_SUBPATH, number);
@@ -2874,12 +2876,10 @@ private:
 // Add and load the session.
 docBroker->addSession(clientSession);
 
-checkDiskSpaceAndWarnClients(true);
-#if !ENABLE_SUPPORT_KEY
+LOOLWSD::checkDiskSpaceAndWarnClients(true);
 // Users of development versions get just an 
info
 // when reaching max documents or connections
-checkSessionLimitsAndWarnClients();
-#endif
+LOOLWSD::checkSessionLimitsAndWarnClients();
 }
 catch (const UnauthorizedRequestException& exc)
 {
diff --git a/wsd/LOOLWSD.hpp b/wsd/LOOLWSD.hpp
index 166de2817..383263314 100644
--- a/wsd/LOOLWSD.hpp
+++ b/wsd/LOOLWSD.hpp
@@ -191,6 +191,10 @@ public:
 /// child kit processes and cleans up DocBrokers.
 static void doHousekeeping();
 
+static void checkDiskSpaceAndWarnClients(const bool cacheLastCheck);
+
+static void checkSessionLimitsAndWarnClients();
+
 /// Close document with @docKey and a @message
 static void closeDocument(const std::string& docKey, const std::string& 
message);
 
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2020-03-11 Thread Michael Meeks (via logerrit)
 wsd/LOOLWSD.cpp |   22 --
 1 file changed, 12 insertions(+), 10 deletions(-)

New commits:
commit 4e5f6bf9d2190d4090e1c67f3d3eff67ec6617e9
Author: Michael Meeks 
AuthorDate: Wed Mar 11 17:05:20 2020 +
Commit: Michael Meeks 
CommitDate: Wed Mar 11 20:10:17 2020 +0100

re-factor: use protocol handler for document broker creation.

Change-Id: If89610c9baebc92bb49b612075118f705cefeeea
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/90343
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Michael Meeks 

diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index 241867af7..2a59b961c 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -236,7 +236,7 @@ namespace
 {
 
 #if ENABLE_SUPPORT_KEY
-inline void shutdownLimitReached(const std::shared_ptr& ws)
+inline void shutdownLimitReached(const 
std::shared_ptr& proto)
 {
 const std::string error = Poco::format(PAYLOAD_UNAVAILABLE_LIMIT_REACHED, 
LOOLWSD::MaxDocuments, LOOLWSD::MaxConnections);
 LOG_INF("Sending client 'hardlimitreached' message: " << error);
@@ -244,10 +244,10 @@ inline void shutdownLimitReached(const 
std::shared_ptr& ws)
 try
 {
 // Let the client know we are shutting down.
-ws->sendMessage(error);
+proto->sendTextMessage(error);
 
 // Shutdown.
-ws->shutdown(WebSocketHandler::StatusCodes::POLICY_VIOLATION);
+proto->shutdown(true, error);
 }
 catch (const std::exception& ex)
 {
@@ -1729,7 +1729,7 @@ std::mutex Connection::Mutex;
 /// May return null if terminating or MaxDocuments limit is reached.
 /// After returning a valid instance DocBrokers must be cleaned up after 
exceptions.
 static std::shared_ptr
-findOrCreateDocBroker(const std::shared_ptr& ws,
+findOrCreateDocBroker(const std::shared_ptr& 
proto,
   const std::string& uri,
   const std::string& docKey,
   const std::string& id,
@@ -1762,8 +1762,9 @@ static std::shared_ptr
 if (docBroker->isMarkedToDestroy())
 {
 LOG_WRN("DocBroker with docKey [" << docKey << "] that is marked 
to be destroyed. Rejecting client request.");
-ws->sendMessage("error: cmd=load kind=docunloading");
-ws->shutdown(WebSocketHandler::StatusCodes::ENDPOINT_GOING_AWAY, 
"error: cmd=load kind=docunloading");
+std::string msg("error: cmd=load kind=docunloading");
+proto->sendTextMessage(msg, msg.size());
+proto->shutdown(true, "error: cmd=load kind=docunloading");
 return nullptr;
 }
 }
@@ -1781,7 +1782,7 @@ static std::shared_ptr
 // Indicate to the client that we're connecting to the docbroker.
 const std::string statusConnect = "statusindicator: connect";
 LOG_TRC("Sending to Client [" << statusConnect << "].");
-ws->sendMessage(statusConnect);
+proto->sendTextMessage(statusConnect, statusConnect.size());
 
 if (!docBroker)
 {
@@ -1791,7 +1792,7 @@ static std::shared_ptr
 {
 LOG_INF("Maximum number of open documents of " << 
LOOLWSD::MaxDocuments << " reached.");
 #if ENABLE_SUPPORT_KEY
-shutdownLimitReached(ws);
+shutdownLimitReached(proto);
 return nullptr;
 #endif
 }
@@ -2832,8 +2833,9 @@ private:
 LOG_INF("URL [" << LOOLWSD::anonymizeUrl(url) << "] is " << 
(isReadOnly ? "readonly" : "writable") << ".");
 
 // Request a kit process for this doc.
-std::shared_ptr docBroker = 
findOrCreateDocBroker(ws, url, docKey, _id, uriPublic);
-if (docBroker)
+std::shared_ptr docBroker = findOrCreateDocBroker(
+std::static_pointer_cast(ws), url, 
docKey, _id, uriPublic);
+ if (docBroker)
 {
 #if MOBILEAPP
 const std::string hostNoTrust;
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2020-03-09 Thread Tomaž Vajngerl (via logerrit)
 wsd/LOOLWSD.cpp |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit c4fcb3eeb5506347976135c821a873ae4058a454
Author: Tomaž Vajngerl 
AuthorDate: Mon Mar 9 10:05:21 2020 +0100
Commit: Tomaž Vajngerl 
CommitDate: Mon Mar 9 11:31:30 2020 +0100

Fix build on android

Change-Id: I4cadfa38ffcaa774f6edf41a9172f1b4b5bbe896
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/90203
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Tomaž Vajngerl 

diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index 8ab895ec8..b009bcaa5 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -357,7 +357,7 @@ void cleanupDocBrokers()
 LOG_END(logger, true);
 }
 
-#if ENABLE_DEBUG
+#if !MOBILEAPP && ENABLE_DEBUG
 if (LOOLWSD::SingleKit && DocBrokers.size() == 0)
 {
 SigUtil::requestShutdown();
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2020-02-29 Thread Jan Holesovsky (via logerrit)
 wsd/LOOLWSD.cpp |6 +-
 wsd/LOOLWSD.hpp |2 ++
 2 files changed, 7 insertions(+), 1 deletion(-)

New commits:
commit 09005eb1cf67b12dd0be7623646c2e900c81b241
Author: Jan Holesovsky 
AuthorDate: Fri Feb 28 14:55:42 2020 +0100
Commit: Michael Meeks 
CommitDate: Sat Feb 29 11:01:00 2020 +0100

android: Don't even try to read these values, seem to trigger an exception.

All the code that is using them is compiled out on Android anyway.

Change-Id: Ica349135202211ecdcb095bb82aa677f2dee19ba
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/89714
Tested-by: Michael Meeks 
Reviewed-by: Michael Meeks 

diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index 5611edba5..61b9d8f09 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -213,7 +213,6 @@ static int careerSpanMs = 0;
 
 /// The timeout for a child to spawn, initially high, then reset to the 
default.
 int ChildSpawnTimeoutMs = CHILD_TIMEOUT_MS * 4;
-bool LOOLWSD::NoCapsForKit = false;
 std::atomic LOOLWSD::NumConnections;
 std::set LOOLWSD::EditFileExtensions;
 
@@ -699,8 +698,11 @@ std::atomic LOOLWSD::NextConnectionId(1);
 std::atomic LOOLWSD::ForKitWritePipe(-1);
 std::atomic LOOLWSD::ForKitProcId(-1);
 #endif
+#if !MOBILEAPP
+bool LOOLWSD::NoCapsForKit = false;
 bool LOOLWSD::NoSeccomp = false;
 bool LOOLWSD::AdminEnabled = true;
+#endif
 #ifdef FUZZER
 bool LOOLWSD::DummyLOK = false;
 std::string LOOLWSD::FuzzFileName;
@@ -1100,9 +1102,11 @@ void LOOLWSD::initialize(Application& self)
 LOOLWSD::MaxConnections = MAX_CONNECTIONS;
 LOOLWSD::MaxDocuments = MAX_DOCUMENTS;
 
+#if !MOBILEAPP
 NoSeccomp = !getConfigValue(conf, "security.seccomp", true);
 NoCapsForKit = !getConfigValue(conf, "security.capabilities", true);
 AdminEnabled = getConfigValue(conf, "admin_console.enable", true);
+#endif
 
 #if ENABLE_SUPPORT_KEY
 const std::string supportKeyString = getConfigValue(conf, 
"support_key", "");
diff --git a/wsd/LOOLWSD.hpp b/wsd/LOOLWSD.hpp
index d14b77ae5..204129d77 100644
--- a/wsd/LOOLWSD.hpp
+++ b/wsd/LOOLWSD.hpp
@@ -49,9 +49,11 @@ public:
 // so just keep these as statics.
 static std::atomic NextConnectionId;
 static unsigned int NumPreSpawnedChildren;
+#if !MOBILEAPP
 static bool NoCapsForKit;
 static bool NoSeccomp;
 static bool AdminEnabled;
+#endif
 static std::atomic ForKitWritePipe;
 static std::atomic ForKitProcId;
 static bool DummyLOK;
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2020-02-18 Thread Ashod Nakashian (via logerrit)
 wsd/LOOLWSD.cpp |   15 ---
 1 file changed, 8 insertions(+), 7 deletions(-)

New commits:
commit 40fd4696116d358749c7f92f6131572a78b5baed
Author: Ashod Nakashian 
AuthorDate: Sat Feb 8 14:41:55 2020 -0500
Commit: Ashod Nakashian 
CommitDate: Tue Feb 18 15:02:46 2020 +0100

wsd: minor cleanup

Change-Id: I5b589d6cdb74f7f3a0c96ca2086500f6975a94b9
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/88369
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Ashod Nakashian 

diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index 518770979..6012202e3 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -615,8 +615,9 @@ public:
 return;
 
 // FIXME: needs wrapping - until then - keep in sync with 
~ConvertToBroker
-Path tempPath = _convertTo? 
Path::forDirectory(Poco::TemporaryFile::tempName("/tmp/convert-to") + "/") :
-
Path::forDirectory(Poco::TemporaryFile::tempName() + "/");
+Path tempPath = Path::forDirectory(
+Poco::TemporaryFile::tempName(_convertTo ? "/tmp/convert-to" : "") 
+ '/');
+LOG_TRC("Creating temporary convert-to path: " << tempPath.toString());
 File(tempPath).createDirectories();
 chmod(tempPath.toString().c_str(), S_IXUSR | S_IWUSR | S_IRUSR);
 
@@ -2100,7 +2101,6 @@ private:
 /// Called after successful socket reads.
 void handleIncomingMessage(SocketDisposition ) override
 {
-// LOG_TRC("* ClientRequestDispatcher::handleIncomingMessage()");
 std::shared_ptr socket = _socket.lock();
 
 #if !MOBILEAPP
@@ -2126,6 +2126,7 @@ private:
 if (!socket->parseHeader("Client", startmessage, request, ))
 return;
 
+LOG_INF("Handling request: " << request.getURI());
 try
 {
 // We may need to re-write the chunks moving the inBuffer.
@@ -2273,7 +2274,11 @@ private:
 }
 catch (const std::exception& exc)
 {
+LOG_INF("#" << socket->getFD() << " Exception while processing 
incoming request: [" <<
+LOOLProtocol::getAbbreviatedMessage(socket->getInBuffer()) 
<< "]: " << exc.what());
+
 // Bad request.
+// NOTE: Check _wsState to choose between HTTP response or 
WebSocket (app-level) error.
 std::ostringstream oss;
 oss << "HTTP/1.1 400\r\n"
 << "Date: " << Util::getHttpTimeNow() << "\r\n"
@@ -2282,10 +2287,6 @@ private:
 << "\r\n";
 socket->send(oss.str());
 socket->shutdown();
-
-// NOTE: Check _wsState to choose between HTTP response or 
WebSocket (app-level) error.
-LOG_INF("#" << socket->getFD() << " Exception while processing 
incoming request: [" <<
-LOOLProtocol::getAbbreviatedMessage(socket->getInBuffer()) 
<< "]: " << exc.what());
 return;
 }
 
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2020-02-07 Thread Michael Meeks (via logerrit)
 wsd/LOOLWSD.cpp |6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

New commits:
commit 39311fdae3658d563adbb8c1844823956a8cd666
Author: Michael Meeks 
AuthorDate: Fri Feb 7 14:14:21 2020 +
Commit: Michael Meeks 
CommitDate: Fri Feb 7 16:39:55 2020 +0100

remove poco Environment call.

Change-Id: I967a42aa3b8a3b9fc44b3dffedef98adc4b94724
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/88198
Reviewed-by: Ashod Nakashian 
Tested-by: Michael Meeks 

diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index 7fa1898ec..518770979 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -8,7 +8,6 @@
  */
 
 #include 
-
 #include "LOOLWSD.hpp"
 #include "ProofKey.hpp"
 
@@ -37,6 +36,7 @@
 // number of child processes, each which handles a viewing (editing) session 
for one document.
 
 #include 
+#include 
 #include 
 
 #include 
@@ -84,7 +84,6 @@ using Poco::Net::PartHandler;
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -157,7 +156,6 @@ using Poco::Net::PartHandler;
 using namespace LOOLProtocol;
 
 using Poco::DirectoryIterator;
-using Poco::Environment;
 using Poco::Exception;
 using Poco::File;
 using Poco::Net::HTTPRequest;
@@ -3351,7 +3349,7 @@ int LOOLWSD::innerMain()
 
 #ifdef __linux
 // down-pay all the forkit linking cost once & early.
-Environment::set("LD_BIND_NOW", "1");
+setenv("LD_BIND_NOW", "1", 1);
 
 #if !MOBILEAPP
 HostIdentifier = Util::rng::getHexString(8);
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2020-02-05 Thread Andras Timar (via logerrit)
 wsd/LOOLWSD.cpp |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

New commits:
commit 4fa8e4ee83f1ae7bd07f6f489802ef62ce0987d0
Author: Andras Timar 
AuthorDate: Wed Feb 5 14:47:14 2020 +0100
Commit: Andras Timar 
CommitDate: Wed Feb 5 14:47:25 2020 +0100

typo: shuting -> shutting

Change-Id: Ia33113b0c624b60479f41c8580e9b3d8d17812f4

diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index db6502eb3..c8f4d0053 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -254,7 +254,7 @@ inline void shutdownLimitReached(WebSocketHandler& ws)
 }
 catch (const std::exception& ex)
 {
-LOG_ERR("Error while shuting down socket on reaching limit: " << 
ex.what());
+LOG_ERR("Error while shutting down socket on reaching limit: " << 
ex.what());
 }
 }
 #endif
@@ -275,7 +275,7 @@ inline void checkSessionLimitsAndWarnClients()
 }
 catch (const std::exception& ex)
 {
-LOG_ERR("Error while shuting down socket on reaching limit: " << 
ex.what());
+LOG_ERR("Error while shutting down socket on reaching limit: " << 
ex.what());
 }
 }
 #endif
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2020-01-23 Thread Miklos Vajna (via logerrit)
 wsd/LOOLWSD.cpp |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

New commits:
commit 9f91b01633de0bcfb2bf6bef930e88dfb0dd45c8
Author: Miklos Vajna 
AuthorDate: Thu Jan 23 10:12:46 2020 +0100
Commit: Miklos Vajna 
CommitDate: Thu Jan 23 11:18:46 2020 +0100

wsd: fix Android build

Don't just rename the variable, also make sure we get the FD before we
reset our local reference to it.

Change-Id: I676f148874831eaf9f37bdcde1216c58f89229e5
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/87244
Reviewed-by: Jan Holesovsky 
Tested-by: Miklos Vajna 

diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index 64351f94a..db6502eb3 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -3131,12 +3131,12 @@ public:
 {
 _acceptPoll.startThread();
 _acceptPoll.insertNewSocket(_serverSocket);
-_serverSocket.reset();
 
 #if MOBILEAPP
-loolwsd_server_socket_fd = serverSocket->getFD();
+loolwsd_server_socket_fd = _serverSocket->getFD();
 #endif
 
+_serverSocket.reset();
 WebServerPoll.startThread();
 
 #if !MOBILEAPP
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2020-01-22 Thread Michael Meeks (via logerrit)
 wsd/LOOLWSD.cpp |   18 ++
 1 file changed, 14 insertions(+), 4 deletions(-)

New commits:
commit c9cfde6d720f8f77f2b8b45ef3a9b04f3cd84cca
Author: Michael Meeks 
AuthorDate: Wed Jan 22 23:24:13 2020 +0100
Commit: Michael Meeks 
CommitDate: Thu Jan 23 00:39:19 2020 +0100

wsd: use port number after, rather than before allocating it.

Particularly printing it on the console, and passing it to the kit.

Change-Id: I158f97b7b219c44c885939d71af2e5e8283be4c2
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/87227
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Michael Meeks 

diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index 58cd41b7d..64351f94a 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -3109,6 +3109,13 @@ public:
 stop();
 }
 
+// allocate port & hold temporarily.
+std::shared_ptr _serverSocket;
+void findClientPort()
+{
+_serverSocket = findServerPort(ClientPortNumber);
+}
+
 void startPrisoners()
 {
 PrisonerPoll.startThread();
@@ -3120,11 +3127,11 @@ public:
 PrisonerPoll.joinThread();
 }
 
-void start(const int port)
+void start()
 {
 _acceptPoll.startThread();
-std::shared_ptr serverSocket(findServerPort(port));
-_acceptPoll.insertNewSocket(serverSocket);
+_acceptPoll.insertNewSocket(_serverSocket);
+_serverSocket.reset();
 
 #if MOBILEAPP
 loolwsd_server_socket_fd = serverSocket->getFD();
@@ -3396,6 +3403,9 @@ int LOOLWSD::innerMain()
 
 ClientRequestDispatcher::InitStaticFileContentCache();
 
+// Allocate our port - passed to prisoners.
+srv.findClientPort();
+
 // Start the internal prisoner server and spawn forkit,
 // which in turn forks first child.
 srv.startPrisoners();
@@ -3447,7 +3457,7 @@ int LOOLWSD::innerMain()
 Util::mapAnonymized("contents", "contents");
 
 // Start the server.
-srv.start(ClientPortNumber);
+srv.start();
 
 /// The main-poll does next to nothing:
 SocketPoll mainWait("main");
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2020-01-22 Thread Miklos Vajna (via logerrit)
 wsd/LOOLWSD.cpp |4 
 1 file changed, 4 insertions(+)

New commits:
commit 9a92cd24153523ee71726bcf1d9bae15ff632ab6
Author: Miklos Vajna 
AuthorDate: Wed Jan 22 08:52:55 2020 +0100
Commit: Miklos Vajna 
CommitDate: Wed Jan 22 09:19:05 2020 +0100

Fix an UB in the DocumentBroker dtor

The problem is that both the DocBrokers map and the instance returned by
Admin::instance() are static, so there it's not safe to assume that by
the time the DocumentBroker dtor runs, the static Admin instance is
still alive. Still, the DocumentBroker dtor calls Admin::instance().

Fix this by clearing the DocBrokers map in LOOLWSD::cleanup(), which is
used exactly to destroy statics in a controlled order.

Sanitizers output was:

wsd/DocumentBroker.cpp:497:23: runtime error: member call on address 
0x024a5ba0 which does not point to an object of type 'Admin'
0x024a5ba0: note: object is of type 'SocketPoll'
 00 00 00 00  50 21 45 01 00 00 00 00  b8 5b 4a 02 00 00 00 00  05 00 00 00 
00 00 00 00  61 64 6d 69
  ^~~
  vptr for 'SocketPoll'
#0 0xa10af3 in DocumentBroker::~DocumentBroker() 
wsd/DocumentBroker.cpp:497:23
...
#17 0x7fa27622ddc9 in exit (/lib64/libc.so.6+0x38dc9)
#18 0x7fa276215f90 in __libc_start_main (/lib64/libc.so.6+0x20f90)
#19 0x670189 in _start 
/home/abuild/rpmbuild/BUILD/glibc-2.26/csu/../sysdeps/x86_64/start.S:120

SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior 
wsd/DocumentBroker.cpp:497:23 in

(Seen during make check CPPUNIT_TEST_NAME="unit-each-view".)

Change-Id: I02ad44deb9de06d9973216428c640248ea2512ce
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/87174
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Miklos Vajna 

diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index bcb0ca141..58cd41b7d 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -3607,6 +3607,10 @@ void LOOLWSD::cleanup()
 #endif
 Socket::InhibitThreadChecks = true;
 SocketPoll::InhibitThreadChecks = true;
+
+// Delete these while the static Admin instance is still alive.
+std::lock_guard docBrokersLock(DocBrokersMutex);
+DocBrokers.clear();
 }
 
 int LOOLWSD::main(const std::vector& /*args*/)
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2019-12-20 Thread Marco Cecchetti (via logerrit)
 wsd/LOOLWSD.cpp |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit 35831935d8cc9a2135c3462157cb14a21b13d067
Author: Marco Cecchetti 
AuthorDate: Thu Dec 19 14:49:12 2019 +0100
Commit: Marco Cecchetti 
CommitDate: Fri Dec 20 20:32:42 2019 +0100

wsd: disable unsupported code on mobile

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

diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index 3a597c4a1..3efed76e9 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -3475,7 +3475,7 @@ int LOOLWSD::innerMain()
 if (timeSinceStartMs > UnitWSD::get().getTimeoutMilliSeconds())
 UnitWSD::get().timeout();
 
-#if ENABLE_DEBUG
+#if ENABLE_DEBUG && !MOBILEAPP
 if (careerSpanMs > 0 && timeSinceStartMs > careerSpanMs)
 {
 LOG_INF(timeSinceStartMs << " milliseconds gone, finishing as 
requested. Setting ShutdownRequestFlag.");
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2019-12-10 Thread Jan Holesovsky (via logerrit)
 wsd/LOOLWSD.cpp |4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

New commits:
commit f71522e7ff7c648ed14f1ef18c2c10f8ef12d997
Author: Jan Holesovsky 
AuthorDate: Mon Dec 9 13:07:25 2019 +0100
Commit: Andras Timar 
CommitDate: Tue Dec 10 16:25:47 2019 +0100

TemplateSaveAs is broken by design, let's disable it.

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

diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index f76aaabc1..faa399756 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -3074,7 +3074,9 @@ private:
 capabilities->set("convert-to", convert_to);
 
 // Supports the TemplateSaveAs in CheckFileInfo?
-capabilities->set("hasTemplateSaveAs", true);
+// TemplateSaveAs is broken by design, disable it everywhere (and
+// remove at some stage too)
+capabilities->set("hasTemplateSaveAs", false);
 
 // Supports the TemplateSource in CheckFileInfo?
 capabilities->set("hasTemplateSource", true);
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2019-11-25 Thread Michael Meeks (via logerrit)
 wsd/LOOLWSD.cpp |   53 +++--
 1 file changed, 23 insertions(+), 30 deletions(-)

New commits:
commit 918d4ae150be391eedc70c4e193265d3b07ac23d
Author: Michael Meeks 
AuthorDate: Mon Nov 25 12:06:07 2019 +
Commit: Michael Meeks 
CommitDate: Mon Nov 25 12:47:17 2019 +

Add quick link to check monitoring.

Change-Id: I069eeaf8464661aaff52f11523d70c40cc81cc46

diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index a5dee7870..c3e22d240 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -18,6 +18,9 @@
 /* Default loleaflet UI used in the admin console URI */
 #define LOOLWSD_TEST_ADMIN_CONSOLE "/loleaflet/dist/admin/admin.html"
 
+/* Default loleaflet UI used in for monitoring URI */
+#define LOOLWSD_TEST_METRICS "/lool/getMetrics"
+
 /* Default loleaflet UI used in the start test URI */
 #define LOOLWSD_TEST_LOLEAFLET_UI "/loleaflet/" LOOLWSD_VERSION_HASH 
"/loleaflet.html"
 
@@ -635,12 +638,23 @@ namespace
 {
 
 #if ENABLE_DEBUG
-inline std::string getLaunchBase(const std::string )
+inline std::string getLaunchBase(bool asAdmin = false)
 {
 std::ostringstream oss;
 oss << "";
 oss << ((LOOLWSD::isSSLEnabled() || LOOLWSD::isSSLTermination()) ? 
"https://; : "http://;);
-oss << credentials;
+
+if (asAdmin)
+{
+auto user = 
LOOLWSD::getConfigValue("admin_console.username", "");
+auto passwd = 
LOOLWSD::getConfigValue("admin_console.password", "");
+
+if (user.empty() || passwd.empty())
+return "";
+
+oss << user << ":" << passwd << "@";
+}
+
 oss << LOOLWSD_TEST_HOST ":";
 oss << ClientPortNumber;
 
@@ -651,7 +665,7 @@ inline std::string getLaunchURI(const std::string )
 {
 std::ostringstream oss;
 
-oss << getLaunchBase("");
+oss << getLaunchBase();
 oss << LOOLWSD::ServiceRoot;
 oss << LOOLWSD_TEST_LOLEAFLET_UI;
 oss << "?file_path=file://";
@@ -661,33 +675,17 @@ inline std::string getLaunchURI(const std::string 
)
 return oss.str();
 }
 
-inline std::string getServiceURI(const std::string )
+inline std::string getServiceURI(const std::string , bool asAdmin = false)
 {
 std::ostringstream oss;
 
-oss << getLaunchBase("");
+oss << getLaunchBase(asAdmin);
 oss << LOOLWSD::ServiceRoot;
 oss << sub;
 
 return oss.str();
 }
 
-inline std::string getAdminURI(const Poco::Util::LayeredConfiguration )
-{
-std::string user = config.getString("admin_console.username", "");
-std::string passwd = config.getString("admin_console.password", "");
-
-if (user.empty() || passwd.empty())
-return "";
-
-std::ostringstream oss;
-
-oss << getLaunchBase(user + ":" + passwd + "@");
-oss << LOOLWSD::ServiceRoot;
-oss << LOOLWSD_TEST_ADMIN_CONSOLE;
-
-return oss.str();
-}
 #endif
 
 } // anonymous namespace
@@ -1207,10 +1205,11 @@ void LOOLWSD::initialize(Application& self)
   << "Calc:" << 
getLaunchURI(LOOLWSD_TEST_DOCUMENT_RELATIVE_PATH_CALC) << '\n'
   << "Impress: " << 
getLaunchURI(LOOLWSD_TEST_DOCUMENT_RELATIVE_PATH_IMPRESS) << std::endl;
 
-const std::string adminURI = getAdminURI(config());
+const std::string adminURI = getServiceURI(LOOLWSD_TEST_ADMIN_CONSOLE, 
true);
 if (!adminURI.empty())
-std::cerr << "\nOr for the admin, capabilities & discovery:\n\n"
+std::cerr << "\nOr for the admin, monitoring, capabilities & 
discovery:\n\n"
   << adminURI << "\n"
+  << getServiceURI(LOOLWSD_TEST_METRICS, true) << "\n"
   << getServiceURI("/hosting/capabilities") << "\n"
   << getServiceURI("/hosting/discovery") << "\n";
 
@@ -3379,13 +3378,7 @@ static LOOLWSDServer srv;
 #if ENABLE_DEBUG
 std::string LOOLWSD::getServerURL()
 {
-std::ostringstream oss;
-
-oss << getLaunchBase("");
-oss << LOOLWSD::ServiceRoot;
-oss << LOOLWSD_TEST_LOLEAFLET_UI;
-
-return oss.str();
+return getServiceURI(LOOLWSD_TEST_LOLEAFLET_UI);
 }
 #endif
 #endif
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

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

2019-11-20 Thread Jan Holesovsky (via logerrit)
 wsd/LOOLWSD.cpp |   22 +++---
 1 file changed, 11 insertions(+), 11 deletions(-)

New commits:
commit 78e3dd0ae6bf6a60767c22946687b5ea554cafc2
Author: Jan Holesovsky 
AuthorDate: Wed Nov 20 18:46:19 2019 +0100
Commit: Jan Holesovsky 
CommitDate: Wed Nov 20 19:41:03 2019 +0100

Revert "killpoco: Remove StringTokenizer from LOOLWSD.cpp."

Blind fix - I've seen a report of a problem with a 'Syntax error' caught
around this code.  Unfortunately cannot reproduce this myself, but
better to revert for now.

This reverts commit f637f4a75af56ae16116a88730660d018f306131.

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

diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index 410769ab6..e7b4f7439 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -92,6 +92,7 @@ using Poco::Net::PartHandler;
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -161,6 +162,7 @@ using Poco::Net::MessageHeader;
 using Poco::Net::NameValueCollection;
 using Poco::Path;
 using Poco::StreamCopier;
+using Poco::StringTokenizer;
 using Poco::TemporaryFile;
 using Poco::URI;
 using Poco::Util::Application;
@@ -2189,21 +2191,19 @@ private:
 }
 else
 {
-// split by /'s and ?'s
-std::vector 
reqPathTokens(LOOLProtocol::tokenize(request.getURI(), 
std::regex(R"(\s*[\/\?]\s*)"), /*skipEmpty =*/ true));
-
-if (reqPathTokens.size() > 1 && reqPathTokens[0] == "lool" && 
reqPathTokens[1] == "clipboard")
+StringTokenizer reqPathTokens(request.getURI(), "/?", 
StringTokenizer::TOK_IGNORE_EMPTY | StringTokenizer::TOK_TRIM);
+if (reqPathTokens.count() > 1 && reqPathTokens[0] == "lool" && 
reqPathTokens[1] == "clipboard")
 {
 //Util::dumpHex(std::cerr, "clipboard:\n", "", 
socket->getInBuffer()); // lots of data ...
 handleClipboardRequest(request, message, disposition);
 }
 else if (!(request.find("Upgrade") != request.end() && 
Poco::icompare(request["Upgrade"], "websocket") == 0) &&
-reqPathTokens.size() > 0 && reqPathTokens[0] == "lool")
+reqPathTokens.count() > 0 && reqPathTokens[0] == "lool")
 {
 // All post requests have url prefix 'lool'.
 handlePostRequest(request, message, disposition);
 }
-else if (reqPathTokens.size() > 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)
 {
 std::string decodedUri; // WOPISrc
@@ -2533,8 +2533,8 @@ private:
 Poco::Net::HTTPResponse response;
 std::shared_ptr socket = _socket.lock();
 
-std::vector 
tokens(LOOLProtocol::tokenize(request.getURI(), std::regex(R"(\s*[\/\?]\s*)")));
-if (tokens.size() > 2 && tokens[2] == "convert-to")
+StringTokenizer tokens(request.getURI(), "/?");
+if (tokens.count() > 2 && tokens[2] == "convert-to")
 {
 // Validate sender - FIXME: should do this even earlier.
 if (!allowConvertTo(socket->clientAddress(), request, true))
@@ -2560,7 +2560,7 @@ private:
 bool bFullSheetPreview = sFullSheetPreview == "true" ? true : 
false;
 
 // prefer what is in the URI
-if (tokens.size() > 3)
+if (tokens.count() > 3)
 format = tokens[3];
 
 bool sent = false;
@@ -2660,7 +2660,7 @@ private:
 }
 return;
 }
-else if (tokens.size() >= 4 && tokens[3] == "insertfile")
+else if (tokens.count() >= 4 && tokens[3] == "insertfile")
 {
 LOG_INF("Insert file request.");
 
@@ -2701,7 +2701,7 @@ private:
 }
 }
 }
-else if (tokens.size() >= 6)
+else if (tokens.count() >= 6)
 {
 LOG_INF("File download request.");
 // TODO: Check that the user in question has access to this file!
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

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

2019-11-12 Thread Ashod Nakashian (via logerrit)
 wsd/LOOLWSD.cpp |2 ++
 1 file changed, 2 insertions(+)

New commits:
commit 4cb038c60a0fdb22274874701c45156fd51bcad4
Author: Ashod Nakashian 
AuthorDate: Tue Nov 12 10:37:00 2019 -0500
Commit: Ashod Nakashian 
CommitDate: Tue Nov 12 16:45:19 2019 +0100

wsd: Destroy ChildProcess instances before exit

ChildProcess instances log in the dtor, and this can
happen after the log subsystem has been destroyed,
because the order of destruction is undefined.
NewChildren is destroyed in exit, at which point
we have no control over the log subsystem.

To avoid this inversion of order, we clear
the NewChildren container before exiting.

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

diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index 4fad66287..6672ec6d2 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -3568,6 +3568,8 @@ int LOOLWSD::innerMain()
 child->terminate();
 }
 
+NewChildren.clear();
+
 #if !MOBILEAPP
 #ifndef KIT_IN_PROCESS
 // Wait for forkit process finish.
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

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

2019-11-04 Thread Tor Lillqvist (via logerrit)
 wsd/LOOLWSD.cpp |3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

New commits:
commit 36b126c745e1e9a4286d43c0fd9688598cffddad
Author: Tor Lillqvist 
AuthorDate: Mon Nov 4 15:21:44 2019 +0200
Commit: Tor Lillqvist 
CommitDate: Mon Nov 4 15:25:01 2019 +0100

Fix build for MOBILEAPP

Change-Id: I410359a8f2e6cda6e0857d370a3b18db68b619e2
Reviewed-on: https://gerrit.libreoffice.org/82013
Reviewed-by: Tor Lillqvist 
Tested-by: Tor Lillqvist 

diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index 0a66ac719..90d0394df 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -3503,13 +3503,14 @@ int LOOLWSD::innerMain()
 
 // atexit handlers tend to free Admin before Documents
 LOG_INF("Exiting. Cleaning up lingering documents.");
+#ifndef MOBILEAPP
 if (!SigUtil::getShutdownRequestFlag())
 {
 // This shouldn't happen, but it's fail safe to always cleanup 
properly.
 LOG_WRN("Exiting WSD without ShutdownRequestFlag. Setting it now.");
 SigUtil::requestShutdown();
 }
-
+#endif
 // Don't stop the DocBroker, they will exit.
 constexpr size_t sleepMs = 500;
 constexpr size_t count = (COMMAND_TIMEOUT_MS * 4) / sleepMs;
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

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

2019-10-08 Thread Muhammet Kara (via logerrit)
 wsd/LOOLWSD.cpp |   30 +++---
 1 file changed, 27 insertions(+), 3 deletions(-)

New commits:
commit 2c167a2df29f358478a801d10a3c09bfad2381bf
Author: Muhammet Kara 
AuthorDate: Mon Oct 7 22:51:38 2019 +0300
Commit: Muhammet Kara 
CommitDate: Tue Oct 8 15:33:37 2019 +0200

wsd: Add FullSheetPreview support for convert-to endpoint

This requires commit 28eb367a3743002ecb1037e2dd2ca3c709f6893d
on core distro/collabora/cp-6.2

Change-Id: I02a5616810a930c6add3c3a0373b5e25e863236c
Reviewed-on: https://gerrit.libreoffice.org/80418
Reviewed-by: Muhammet Kara 
Tested-by: Muhammet Kara 

diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index 4559f4c80..d0dd39878 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -2501,6 +2501,18 @@ private:
 return "application/octet-stream";
 }
 
+static bool isSpreadsheet(const std::string& fileName)
+{
+std::string sContentType = getContentType(fileName);
+
+if (sContentType == "application/vnd.oasis.opendocument.spreadsheet"
+|| sContentType == 
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
+|| sContentType == "application/vnd.ms-excel")
+return true;
+else
+return false;
+}
+
 void handlePostRequest(const Poco::Net::HTTPRequest& request,
Poco::MemoryInputStream& message,
SocketDisposition )
@@ -2531,7 +2543,10 @@ private:
 ConvertToPartHandler handler(/*convertTo =*/ true);
 HTMLForm form(request, message, handler);
 
+std::string sOptions("");
 std::string format = (form.has("format") ? form.get("format") : 
"");
+std::string sFullSheetPreview = (form.has("FullSheetPreview") ? 
form.get("FullSheetPreview") : "");
+bool bFullSheetPreview = sFullSheetPreview == "true" ? true : 
false;
 
 // prefer what is in the URI
 if (tokens.count() > 3)
@@ -2545,6 +2560,15 @@ private:
 Poco::URI uriPublic = DocumentBroker::sanitizeURI(fromPath);
 const std::string docKey = 
DocumentBroker::getDocKey(uriPublic);
 
+if (bFullSheetPreview && format == "pdf" && 
isSpreadsheet(fromPath))
+{
+sOptions += std::string(",FullSheetPreview=") + 
sFullSheetPreview + std::string("FULLSHEETPREVEND");
+}
+else
+{
+bFullSheetPreview = false;
+}
+
 // This lock could become a bottleneck.
 // In that case, we can use a pool and index by publicPath.
 std::unique_lock 
docBrokersLock(DocBrokersMutex);
@@ -2566,7 +2590,7 @@ private:
 nullptr, _id, uriPublic, docBroker, isReadOnly, 
"nocliphost");
 if (clientSession)
 {
-disposition.setMove([docBroker, clientSession, format]
+disposition.setMove([docBroker, clientSession, format, 
sOptions]
 (const std::shared_ptr 
)
 {
 // Perform all of this after removing the socket
@@ -2577,7 +2601,7 @@ private:
 // We no longer own this socket.
 moveSocket->setThreadOwner(std::thread::id(0));
 
-docBroker->addCallback([docBroker, moveSocket, 
clientSession, format]()
+docBroker->addCallback([docBroker, moveSocket, 
clientSession, format, sOptions]()
 {
 auto streamSocket = 
std::static_pointer_cast(moveSocket);
 clientSession->setSaveAsSocket(streamSocket);
@@ -2603,7 +2627,7 @@ private:
 URI::encode(toJailURL, "", encodedTo);
 
 // Convert it to the requested format.
-const auto saveas = "saveas url=" + encodedTo + " 
format=" + format + " options=";
+const auto saveas = "saveas url=" + encodedTo + " 
format=" + format + " options=" + sOptions;
 std::vector saveasRequest(saveas.begin(), 
saveas.end());
 clientSession->handleMessage(true, WSOpCode::Text, 
saveasRequest);
 });
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

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

2019-08-21 Thread Miklos Vajna (via logerrit)
 wsd/LOOLWSD.cpp |2 --
 1 file changed, 2 deletions(-)

New commits:
commit 7952bfc32f3ad978a3411ae6578c62528292c7b2
Author: Miklos Vajna 
AuthorDate: Wed Aug 21 09:13:01 2019 +0200
Commit: Miklos Vajna 
CommitDate: Wed Aug 21 09:13:01 2019 +0200

wsd: fix assertion failure on 'make run'

loolwsd: ./common/Util.hpp:918: void Util::RuntimeConstant::set(const 
T &) [T = bool]: Assertion `!_initialized' failed.

Probably introduced in commit 3c1a130004845c99a159d634eb79474ff3c8d353
(wsd: fix build, with argument "--disable-ssl", 2019-08-20).

Change-Id: Ia7c310f1a8d6ed1b3b69bd91f9e117b97d15e7d7

diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index 7fa2072e7..6bf628632 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -1030,7 +1030,6 @@ void LOOLWSD::initialize(Application& self)
 
 #if ENABLE_SSL
 LOOLWSD::SSLEnabled.set(getConfigValue(conf, "ssl.enable", true));
-LOOLWSD::SSLEnabled.set(false);
 #endif
 
 if (LOOLWSD::isSSLEnabled())
@@ -1044,7 +1043,6 @@ void LOOLWSD::initialize(Application& self)
 
 #if ENABLE_SSL
 LOOLWSD::SSLTermination.set(getConfigValue(conf, "ssl.termination", 
true));
-LOOLWSD::SSLTermination.set(false);
 #endif
 
 std::string allowedLanguages(config().getString("allowed_languages"));
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

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

2019-08-20 Thread Tor Lillqvist (via logerrit)
 wsd/LOOLWSD.cpp |2 ++
 wsd/LOOLWSD.hpp |   10 ++
 2 files changed, 12 insertions(+)

New commits:
commit 1d3ac69ffd5e4024878d87409ccb87c83cbd37c3
Author: Tor Lillqvist 
AuthorDate: Tue Aug 20 11:20:22 2019 +0300
Commit: Tor Lillqvist 
CommitDate: Tue Aug 20 10:55:32 2019 +0200

Avoid some "RuntimeConstant instance read before being initialized" issues

(In the !ENABLE_SSL case.)

Possibly the SSL or not ifdeffery could be cleaned up a bit more.

Change-Id: I0c9b4e956dcd317d6622a7394044fed0c4f2d976
Reviewed-on: https://gerrit.libreoffice.org/77780
Reviewed-by: Tor Lillqvist 
Tested-by: Tor Lillqvist 

diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index dd62d2929..e0518479d 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -710,8 +710,10 @@ std::string LOOLWSD::ConfigDir = LOOLWSD_CONFIGDIR 
"/conf.d";
 std::string LOOLWSD::LogLevel = "trace";
 bool LOOLWSD::AnonymizeUserData = false;
 std::uint64_t LOOLWSD::AnonymizationSalt = 82589933;
+#if ENABLE_SSL
 Util::RuntimeConstant LOOLWSD::SSLEnabled;
 Util::RuntimeConstant LOOLWSD::SSLTermination;
+#endif
 unsigned LOOLWSD::MaxConnections;
 unsigned LOOLWSD::MaxDocuments;
 std::string LOOLWSD::OverrideWatermark;
diff --git a/wsd/LOOLWSD.hpp b/wsd/LOOLWSD.hpp
index 2e6c68e70..7c4103e3b 100644
--- a/wsd/LOOLWSD.hpp
+++ b/wsd/LOOLWSD.hpp
@@ -92,12 +92,20 @@ public:
 
 static bool isSSLEnabled()
 {
+#if ENABLE_SSL
 return LOOLWSD::SSLEnabled.get();
+#else
+return false;
+#endif
 }
 
 static bool isSSLTermination()
 {
+#if ENABLE_SSL
 return LOOLWSD::SSLTermination.get();
+#else
+return false;
+#endif
 }
 
 /// Return true iff extension is marked as view action in discovery.xml.
@@ -182,8 +190,10 @@ protected:
 void cleanup();
 
 private:
+#if ENABLE_SSL
 static Util::RuntimeConstant SSLEnabled;
 static Util::RuntimeConstant SSLTermination;
+#endif
 
 void initializeSSL();
 void displayHelp();
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

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

2019-07-25 Thread Jan Holesovsky (via logerrit)
 wsd/LOOLWSD.cpp |2 ++
 1 file changed, 2 insertions(+)

New commits:
commit 82bcd8db732b7be5b3f43e12d5e6ef1cf13d7fea
Author: Jan Holesovsky 
AuthorDate: Thu Jul 25 12:59:18 2019 +0200
Commit: Jan Holesovsky 
CommitDate: Thu Jul 25 13:03:09 2019 +0200

Add a comment where the HULLO response is handled.

Useful for git grep HULLO :-)

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

diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index fc5de67a3..d777b38bf 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -2181,6 +2181,8 @@ private:
 socket->eraseFirstInputBytes(map);
 #else
 Poco::Net::HTTPRequest request;
+// The 2nd parameter is the response to the HULLO message (which we
+// respond with the path of the document)
 handleClientWsUpgrade(request, 
std::string(socket->getInBuffer().data(), socket->getInBuffer().size()), 
disposition);
 socket->getInBuffer().clear();
 #endif
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

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

2019-06-21 Thread Michael Meeks (via logerrit)
 wsd/LOOLWSD.cpp |3 +++
 1 file changed, 3 insertions(+)

New commits:
commit 38934525dd11e45b6779b3da54f58bdf3ca2711e
Author: Michael Meeks 
AuthorDate: Fri Jun 21 16:02:00 2019 +0100
Commit: Michael Meeks 
CommitDate: Fri Jun 21 17:06:43 2019 +0200

Cleanup sensibly on exceptions.

Otherwise atexit handlers can get very upset.

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

diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index 01780a86a..420300a79 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -3370,6 +3370,8 @@ void LOOLWSD::cleanup()
 }
 #endif
 #endif
+Socket::InhibitThreadChecks = true;
+SocketPoll::InhibitThreadChecks = true;
 }
 
 int LOOLWSD::main(const std::vector& /*args*/)
@@ -3384,6 +3386,7 @@ int LOOLWSD::main(const std::vector& 
/*args*/)
 returnValue = innerMain();
 } catch (const std::runtime_error& e) {
 LOG_FTL(e.what());
+cleanup();
 throw;
 } catch (...) {
 cleanup();
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

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

2019-06-04 Thread Jan Holesovsky (via logerrit)
 wsd/LOOLWSD.cpp |   11 ---
 1 file changed, 8 insertions(+), 3 deletions(-)

New commits:
commit 230aa62d17e4237e344fcf7d95491dbbd97ec660
Author: Jan Holesovsky 
AuthorDate: Tue Jun 4 14:45:26 2019 +0200
Commit: Jan Holesovsky 
CommitDate: Tue Jun 4 14:55:08 2019 +0200

Answer 404 when the file to download does not exist.

This gives a better idea what has happened to those using the
Download_As postMessage.  Without this, the attempted download just gets
stuck.

Change-Id: Ic23bbca3761d795251664cf09956468fab13ed80
Reviewed-on: https://gerrit.libreoffice.org/73448
Reviewed-by: Michael Meeks 
Tested-by: Michael Meeks 
(cherry picked from commit 00c02138645c89560130be759500cfa0dad86fa8)
Reviewed-on: https://gerrit.libreoffice.org/73450
Reviewed-by: Jan Holesovsky 
Tested-by: Jan Holesovsky 

diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index 80f657b22..01780a86a 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -2540,7 +2540,6 @@ private:
 + JAILED_DOCUMENT_ROOT + tokens[4] + "/" + 
fileName);
 const std::string filePathAnonym = 
LOOLWSD::anonymizeUrl(filePath.toString());
 LOG_INF("HTTP request for: " << filePathAnonym);
-bool responded = false;
 if (filePath.isAbsolute() && File(filePath).exists())
 {
 const Poco::URI postRequestUri(request.getURI());
@@ -2565,7 +2564,6 @@ private:
 try
 {
 HttpHelper::sendFile(socket, filePath.toString(), 
contentType, response);
-responded = true;
 }
 catch (const Exception& exc)
 {
@@ -2578,8 +2576,15 @@ private:
 else
 {
 LOG_ERR("Download file [" << filePathAnonym << "] not found.");
+std::ostringstream oss;
+oss << "HTTP/1.1 404 Not Found\r\n"
+<< "Date: " << 
Poco::DateTimeFormatter::format(Poco::Timestamp(), 
Poco::DateTimeFormat::HTTP_FORMAT) << "\r\n"
+<< "User-Agent: " << HTTP_AGENT_STRING << "\r\n"
+<< "Content-Length: 0\r\n"
+<< "\r\n";
+socket->send(oss.str());
+socket->shutdown();
 }
-(void)responded;
 return;
 }
 
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

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

2019-05-27 Thread Libreoffice Gerrit user
 wsd/LOOLWSD.cpp |4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

New commits:
commit 6ad5f3a50984f68c40f4d0282447f979e95ee840
Author: Michael Meeks 
AuthorDate: Mon May 27 22:22:13 2019 +0100
Commit: Michael Meeks 
CommitDate: Mon May 27 23:16:47 2019 +0100

re-order to fix threading; probable mis-merge.

Change-Id: Id59042248db7572add2d06f62cd8f1d4969ed889

diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index 8e43fe313..28c91dbdf 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -2451,7 +2451,10 @@ private:
 sent = true;
 }
 else
+{
 LOG_WRN("Failed to create Client Session with id [" << _id 
<< "] on docKey [" << docKey << "].");
+cleanupDocBrokers();
+}
 }
 
 if (!sent)
@@ -2706,7 +2709,6 @@ private:
 else
 {
 LOG_WRN("Failed to create Client Session with id [" << _id 
<< "] on docKey [" << docKey << "].");
-cleanupDocBrokers();
 }
 }
 else
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

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

2019-05-27 Thread Libreoffice Gerrit user
 wsd/LOOLWSD.cpp |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit 1f67481fdbef914cbd7a37d59874bae65d4570bb
Author: Andras Timar 
AuthorDate: Mon May 27 13:58:02 2019 +0200
Commit: Andras Timar 
CommitDate: Mon May 27 13:58:02 2019 +0200

typo: retreieved -> retrieved

Change-Id: Ib991569167711ebfe057daf1e2ca89ce809d35c4

diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index 98a97fb9f..8e43fe313 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -214,7 +214,7 @@ std::set LOOLWSD::EditFileExtensions;
 
 #if MOBILEAPP
 
-// Or can this be retreieved in some other way?
+// Or can this be retrieved in some other way?
 int LOOLWSD::prisonerServerSocketFD;
 
 #else
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

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

2019-03-30 Thread Libreoffice Gerrit user
 wsd/LOOLWSD.cpp |2 ++
 1 file changed, 2 insertions(+)

New commits:
commit 38bb1db96c34ea7937c5061ef3caa192cd8b919f
Author: Michael Meeks 
AuthorDate: Sat Mar 30 11:38:17 2019 +
Commit: Michael Meeks 
CommitDate: Sat Mar 30 17:50:43 2019 +0100

Only erase buffer if socket is not shutting down.

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

diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index 2093211f7..095795cc1 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -2131,6 +2131,7 @@ private:
 << "\r\n";
 socket->send(oss.str());
 socket->shutdown();
+return;
 }
 }
 }
@@ -2149,6 +2150,7 @@ private:
 // NOTE: Check _wsState to choose between HTTP response or 
WebSocket (app-level) error.
 LOG_INF("#" << socket->getFD() << " Exception while processing 
incoming request: [" <<
 LOOLProtocol::getAbbreviatedMessage(socket->getInBuffer()) 
<< "]: " << exc.what());
+return;
 }
 
 // if we succeeded - remove the request from our input buffer
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

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

2019-02-20 Thread Libreoffice Gerrit user
 wsd/LOOLWSD.cpp |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

New commits:
commit f7de69fcbef4fc4b6db78fc72749fd009c4e2ebb
Author: Andras Timar 
AuthorDate: Wed Feb 20 13:52:46 2019 +0100
Commit: Andras Timar 
CommitDate: Wed Feb 20 13:52:46 2019 +0100

 fix release build

Change-Id: I20a65d878aa931219af12aa1ada7cf90324ffda7

diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index 1381b98b2..0919828ca 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -3057,7 +3057,7 @@ private:
 static LOOLWSDServer srv;
 
 #if !MOBILEAPP
-
+#if ENABLE_DEBUG
 std::string LOOLWSD::getServerURL()
 {
 std::ostringstream oss;
@@ -3068,7 +3068,7 @@ std::string LOOLWSD::getServerURL()
 
 return oss.str();
 }
-
+#endif
 #endif
 
 int LOOLWSD::innerMain()
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

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

2019-02-13 Thread Libreoffice Gerrit user
 wsd/LOOLWSD.cpp |4 
 1 file changed, 4 insertions(+)

New commits:
commit 5849a8f8a36276b258c7094fa375c9a3ab804071
Author: Tor Lillqvist 
AuthorDate: Wed Feb 13 19:50:37 2019 +0200
Commit: Tor Lillqvist 
CommitDate: Wed Feb 13 19:50:54 2019 +0200

getServerURL() is not used in MOBILEAPP

Change-Id: I30a96c89884b6259b0a2fcd5bc5d4bc104569913

diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index fccb86ef9..dc949e523 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -3063,6 +3063,8 @@ private:
 
 static LOOLWSDServer srv;
 
+#if !MOBILEAPP
+
 std::string LOOLWSD::getServerURL()
 {
 std::ostringstream oss;
@@ -3074,6 +3076,8 @@ std::string LOOLWSD::getServerURL()
 return oss.str();
 }
 
+#endif
+
 int LOOLWSD::innerMain()
 {
 #if !defined FUZZER && !MOBILEAPP
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

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

2018-12-17 Thread Libreoffice Gerrit user
 wsd/LOOLWSD.cpp |7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

New commits:
commit 6c08d7e3c818c4a876052c454c91633c17da0cad
Author: Jan Holesovsky 
AuthorDate: Mon Dec 17 12:46:34 2018 +0100
Commit: Jan Holesovsky 
CommitDate: Mon Dec 17 13:05:14 2018 +0100

capabilities: Add 'version' and 'hasTemplateSaveAs'.

hasTemplateSaveAs is not supported yet.

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

diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index 87cbd070c..7907fbf3d 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -2777,10 +2777,15 @@ private:
 Poco::Dynamic::Var available = allowConvertTo(socket->clientAddress(), 
request);
 convert_to->set("available", available);
 
-// Compose the content of http://server/hosting/capabilities
 Poco::JSON::Object::Ptr capabilities = new Poco::JSON::Object;
 capabilities->set("convert-to", convert_to);
 
+// Supports the TemplateSaveAs in CheckFileInfo?
+capabilities->set("hasTemplateSaveAs", false);
+
+// Version
+capabilities->set("version", LOOLWSD_VERSION);
+
 std::ostringstream ostrJSON;
 capabilities->stringify(ostrJSON);
 return ostrJSON.str();
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2018-11-07 Thread Libreoffice Gerrit user
 wsd/LOOLWSD.cpp |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit 9f31063bd619345c7e33f16a2c282bdcae365de1
Author: Michael Meeks 
AuthorDate: Thu Nov 8 02:10:03 2018 +
Commit: Michael Meeks 
CommitDate: Thu Nov 8 02:12:02 2018 +

Don't sniff the inside of SSL sockets for SSL headers.

We might find a websocket we don't like.

Change-Id: Id13628252e01501d6cc209f4d572d8da16a7a658

diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index 15a9c9c0a..438004b7f 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -2008,7 +2008,7 @@ private:
 std::shared_ptr socket = _socket.lock();
 
 #ifndef MOBILEAPP
-if (socket->sniffSSL())
+if (!LOOLWSD::isSSLEnabled() && socket->sniffSSL())
 {
 LOG_ERR("Looks like SSL/TLS traffic on plain http port");
 std::ostringstream oss;
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2018-11-06 Thread Libreoffice Gerrit user
 wsd/LOOLWSD.cpp |2 --
 1 file changed, 2 deletions(-)

New commits:
commit 0fb89bc4d025b51a5f142e51e8cb9d471610595a
Author: Miklos Vajna 
AuthorDate: Tue Nov 6 09:08:50 2018 +0100
Commit: Miklos Vajna 
CommitDate: Tue Nov 6 09:09:35 2018 +0100

wsd: remove the last nested #ifndef

Found by the new readability-redundant-pp tool from dev-tools.git.

diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index de83d4b8f..2c31e88c6 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -1330,12 +1330,10 @@ void LOOLWSD::handleOption(const std::string& 
optionName,
 if (masterPort)
 MasterPortNumber = std::stoi(masterPort);
 
-#ifndef MOBILEAPP
 static const char* latencyMs = std::getenv("LOOL_DELAY_SOCKET_MS");
 if (latencyMs)
 SimulatedLatencyMs = std::stoi(latencyMs);
 #endif
-#endif
 
 #ifdef FUZZER
 if (optionName == "dummy-lok")
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2018-11-02 Thread Libreoffice Gerrit user
 wsd/LOOLWSD.cpp |4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

New commits:
commit 4a24055a74308b13f1f9b23f33a309bc42e63b5f
Author: Tor Lillqvist 
AuthorDate: Fri Nov 2 12:38:31 2018 +0200
Commit: Tor Lillqvist 
CommitDate: Fri Nov 2 12:39:11 2018 +0200

Bin one case of nested #ifndef MOBILEAPP

(Might be more. Is there some tool to automatically detect this?)

diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index 7af8b7311..de83d4b8f 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -1555,10 +1555,8 @@ bool LOOLWSD::createForKit()
 if (UnitWSD::get().hasKitHooks())
 args.push_back("--unitlib=" + UnitTestLibrary);
 
-#ifndef MOBILEAPP
 if (DisplayVersion)
 args.push_back("--version");
-#endif
 
 if (NoCapsForKit)
 args.push_back("--nocaps");
@@ -1612,7 +1610,7 @@ bool LOOLWSD::createForKit()
 #endif
 }
 
-#endif
+#endif // !MOBILEAPP
 
 #ifdef FUZZER
 std::mutex Connection::Mutex;
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2018-10-30 Thread Libreoffice Gerrit user
 wsd/LOOLWSD.cpp |4 
 1 file changed, 4 deletions(-)

New commits:
commit dd3d50c1b3b339998f54aad9bc58083a8ad23487
Author: Tor Lillqvist 
AuthorDate: Tue Oct 30 22:06:25 2018 +0200
Commit: Tor Lillqvist 
CommitDate: Tue Oct 30 22:09:52 2018 +0200

Reduce MOBILEAPP ifdef clutter a little bit

This means some no-op UnitWSD functions will get called, but so what.

Change-Id: Ibdce82d9933699fe15947daea221ad67148dfddd

diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index e7e49e021..8d89e65e5 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -3171,9 +3171,7 @@ int LOOLWSD::innerMain()
 std::cerr << "Ready to accept connections on port " << ClientPortNumber << 
 ".\n" << std::endl;
 #endif
 
-#ifndef MOBILEAPP
 const auto startStamp = std::chrono::steady_clock::now();
-#endif
 
 while (!TerminationFlag && !ShutdownRequestFlag)
 {
@@ -3188,7 +3186,6 @@ int LOOLWSD::innerMain()
 // Wake the prisoner poll to spawn some children, if necessary.
 PrisonerPoll.wakeup();
 
-#ifndef MOBILEAPP
 const std::chrono::milliseconds::rep timeSinceStartMs = 
std::chrono::duration_cast(
 std::chrono::steady_clock::now() - 
startStamp).count();
 
@@ -3203,7 +3200,6 @@ int LOOLWSD::innerMain()
 break;
 }
 #endif
-#endif
 }
 // Stop the listening to new connections
 // and wait until sockets close.
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2018-10-25 Thread Libreoffice Gerrit user
 wsd/LOOLWSD.cpp |   19 +++
 1 file changed, 15 insertions(+), 4 deletions(-)

New commits:
commit bf2dcdc01f04a440c8a12d5f5e212d9bdd39c1f6
Author: Tamás Zolnai 
AuthorDate: Thu Oct 25 22:24:00 2018 +0200
Commit: Tamás Zolnai 
CommitDate: Thu Oct 25 22:25:34 2018 +0200

Have a better log for convert-to denial

Change-Id: I5c8d367b3f82d47a45df8c298e39515bc89f7b0d

diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index 2af6a1591..c0db3952a 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -1940,12 +1940,19 @@ public:
 }
 return hosts.match(address);
 }
-bool allowConvertTo(const std::string , const 
Poco::Net::HTTPRequest& request)
+bool allowConvertTo(const std::string , const 
Poco::Net::HTTPRequest& request, bool report = false)
 {
 std::string addressToCheck = address;
 std::string hostToCheck = request.getHost();
 bool allow = allowPostFrom(addressToCheck) || 
StorageBase::allowedWopiHost(hostToCheck);
 
+if(!allow)
+{
+if(report)
+LOG_ERR("Requesting address is denied: " << addressToCheck);
+return false;
+}
+
 // Handle forwarded header and make sure all participating IPs are 
allowed
 if(request.has("X-Forwarded-For"))
 {
@@ -1965,6 +1972,12 @@ public:
 // We can't find out the hostname, check the IP only
 allow &= allowPostFrom(addressToCheck);
 }
+if(!allow)
+{
+if(report)
+LOG_ERR("Requesting address is denied: " << 
addressToCheck);
+return false;
+}
 }
 }
 return allow;
@@ -2287,10 +2300,8 @@ private:
 
 std::string format = (form.has("format") ? form.get("format") : 
"");
 
-if (!allowConvertTo(socket->clientAddress(), request))
+if (!allowConvertTo(socket->clientAddress(), request, true))
 {
-LOG_ERR("client address DENY: " << socket->clientAddress());
-
 std::ostringstream oss;
 oss << "HTTP/1.1 403\r\n"
 << "Date: " << 
Poco::DateTimeFormatter::format(Poco::Timestamp(), 
Poco::DateTimeFormat::HTTP_FORMAT) << "\r\n"
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2018-10-24 Thread Libreoffice Gerrit user
 wsd/LOOLWSD.cpp |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit 18eb13438487290a7d4928381d6ed073134d0ea8
Author: Tamás Zolnai 
AuthorDate: Wed Oct 24 13:09:11 2018 +0200
Commit: Tamás Zolnai 
CommitDate: Wed Oct 24 13:09:11 2018 +0200

Need to use clientHost here

Change-Id: I170e1d24e1a71749c3262c01a83251c6c157f6eb

diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index 0b6ee1a61..d3495e5f3 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -1961,7 +1961,7 @@ public:
 }
 }
 }
-return allowPostFrom(clientAddress) || 
StorageBase::allowedWopiHost(request.getHost());
+return allowPostFrom(clientAddress) || 
StorageBase::allowedWopiHost(clientHost);
 }
 
 private:
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2018-10-16 Thread Libreoffice Gerrit user
 wsd/LOOLWSD.cpp |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit a959056967d354243e7eaa6c52357efc4d5adba7
Author: Miklos Vajna 
AuthorDate: Tue Oct 16 09:12:53 2018 +0200
Commit: Miklos Vajna 
CommitDate: Tue Oct 16 09:14:13 2018 +0200

wsd: unnecesary value parameter in LOOLWSD

diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index e7d99b5ca..6a559f025 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -2758,7 +2758,7 @@ private:
 /// to the @clientSockets' poll when created with @factory.
 std::shared_ptr getServerSocket(ServerSocket::Type type, int 
port,
   SocketPoll ,
-  
std::shared_ptr factory)
+  const 
std::shared_ptr& factory)
 {
 auto serverSocket = std::make_shared(
 type == ServerSocket::Type::Local ? Socket::Type::IPv4 : 
ClientPortProto,
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2018-10-15 Thread Libreoffice Gerrit user
 wsd/LOOLWSD.cpp |   10 ++
 1 file changed, 6 insertions(+), 4 deletions(-)

New commits:
commit 859d799f5c70c55584b04ff322b6f68907780d35
Author: Tor Lillqvist 
AuthorDate: Mon Oct 15 23:56:04 2018 +0300
Commit: Tor Lillqvist 
CommitDate: Tue Oct 16 01:49:46 2018 +0300

Do run some cleanups on return from LOOLWSD::innerMain() in the mobile app 
case

Also, re-initialise the lovely TerminationFlag to false in
LOOLWSD::main().

Change-Id: I8f53e8c809583f931435e6f80324d4438cca4b2a

diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index 1b5dd8917..e7d99b5ca 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -3010,9 +3010,6 @@ int LOOLWSD::innerMain()
 }
 LOG_TRC("Loop finished. TerminationFlag=" << TerminationFlag);
 
-// No point in doing any orderly shutdown on mobile, we will never exit 
intentionally, the OS will
-// kill us.
-#ifndef MOBILEAPP
 // Stop the listening to new connections
 // and wait until sockets close.
 LOG_INF("Stopping server socket listening. ShutdownRequestFlag: " <<
@@ -3053,7 +3050,7 @@ int LOOLWSD::innerMain()
 
 DocBrokers.clear();
 
-#ifndef KIT_IN_PROCESS
+#if !defined(KIT_IN_PROCESS) && !defined(MOBILEAPP)
 // Terminate child processes
 LOG_INF("Requesting forkit process " << ForKitProcId << " to terminate.");
 SigUtil::killChild(ForKitProcId);
@@ -3068,6 +3065,7 @@ int LOOLWSD::innerMain()
 child->terminate();
 }
 
+#ifndef MOBILEAPP
 #ifndef KIT_IN_PROCESS
 // Wait for forkit process finish.
 LOG_INF("Waiting for forkit process to exit");
@@ -3111,6 +3109,10 @@ void LOOLWSD::cleanup()
 
 int LOOLWSD::main(const std::vector& /*args*/)
 {
+#ifdef MOBILEAPP
+TerminationFlag = false;
+#endif
+
 int returnValue;
 
 try {
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2018-10-15 Thread Libreoffice Gerrit user
 wsd/LOOLWSD.cpp |1 +
 1 file changed, 1 insertion(+)

New commits:
commit 843e74e533d9e161a9b7a92680103a25ac41447c
Author: Tor Lillqvist 
AuthorDate: Mon Oct 15 18:51:56 2018 +0300
Commit: Tor Lillqvist 
CommitDate: Tue Oct 16 01:02:00 2018 +0300

Log what TerminationFlag is after the loop in innerMain()

Change-Id: Ib53dc7d760a89a72b47f575ba2787d08cdcd29ec

diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index 8d2544e3d..1468d28c1 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -3010,6 +3010,7 @@ int LOOLWSD::innerMain()
 #endif
 #endif
 }
+LOG_TRC("Loop finished. TerminationFlag=" << TerminationFlag);
 
 // No point in doing any orderly shutdown on mobile, we will never exit 
intentionally, the OS will
 // kill us.
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2018-10-01 Thread Libreoffice Gerrit user
 wsd/LOOLWSD.cpp |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit de48e47a17b248715346053a868db24a36dc75b5
Author: Andras Timar 
AuthorDate: Mon Oct 1 19:42:09 2018 +0200
Commit: Andras Timar 
CommitDate: Mon Oct 1 19:43:22 2018 +0200

typo: BUILDLING_TESTS -> BUILDING_TESTS

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

diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index 8ef290914..baff3d518 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -2804,7 +2804,7 @@ private:
 std::shared_ptr socket = getServerSocket(
 ServerSocket::Type::Public, port, WebServerPoll, factory);
 #ifdef MOBILEAPP
-#ifdef BUILDLING_TESTS
+#ifdef BUILDING_TESTS
 while (!socket)
 {
 ++port;
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2018-08-23 Thread Libreoffice Gerrit user
 wsd/LOOLWSD.cpp |8 
 1 file changed, 8 insertions(+)

New commits:
commit 3e202e8ed141817ca83cc2127f7004f726e1ba29
Author: YiiChang Yen 
AuthorDate: Mon Jul 16 09:38:22 2018 +0800
Commit: Andras Timar 
CommitDate: Thu Aug 23 09:52:28 2018 +0200

ossii# wsd: Add lost config settings for default value.

We lost default value for(POCO setting) but loolwsd.xml had:

pureAge, purgeCount, rotationOnOpen and archive

so set them.

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

diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index 502f6d7c3..7d1436897 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -716,6 +716,14 @@ void LOOLWSD::initialize(Application& self)
 { "logging.file.property[2]", "true" },
 { "logging.file.property[3][@name]", "flush" },
 { "logging.file.property[3]", "false" },
+{ "logging.file.property[4][@name]", "purgeAge" },
+{ "logging.file.property[4]", "10 days" },
+{ "logging.file.property[5][@name]", "purgeCount" },
+{ "logging.file.property[5]", "10" },
+{ "logging.file.property[6][@name]", "rotationOnOpen" },
+{ "logging.file.property[6]", "true" },
+{ "logging.file.property[7][@name]", "archive" },
+{ "logging.file.property[7]", "false" },
 { "trace[@enable]", "false" },
 { "trace.path[@compress]", "true" },
 { "trace.path[@snapshot]", "false" },
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2018-06-14 Thread Ashod Nakashian
 wsd/LOOLWSD.cpp |   73 +---
 1 file changed, 38 insertions(+), 35 deletions(-)

New commits:
commit fbc86814062b4bb55ac48a526473580444e11ec0
Author: Ashod Nakashian 
Date:   Fri Feb 23 20:59:59 2018 -0500

wsd: refactor diskpace and session limit checks

Checks are now done after adding new sessions
to DocBroker rather than before, so the current
session being added doesn't need special handling.

The checks for diskspace is separated from that
of the number of sessions as they are unrelated.

Also, no reason to do the checks for convert-to
requests, since these don't have interactive
clients, rather the connections are closed after
the conversion.

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

diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index a66d0306d..25ec59258 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -216,23 +216,24 @@ inline void shutdownLimitReached(WebSocketHandler& ws)
 }
 #endif
 
-inline void infoLimitReached(const WebSocketHandler* ws)
+inline void checkSessionLimitsAndWarnClients()
 {
-const std::string info = Poco::format(PAYLOAD_INFO_LIMIT_REACHED, 
LOOLWSD::MaxDocuments, LOOLWSD::MaxConnections);
-LOG_INF("Sending client 'limitreached' message: " << info);
-
-try
-{
-Util::alertAllUsers(info);
-ws->sendMessage(info);
-}
-catch (const std::exception& ex)
+if (DocBrokers.size() > LOOLWSD::MaxDocuments || LOOLWSD::NumConnections 
>= LOOLWSD::MaxConnections)
 {
-LOG_ERR("Error while shuting down socket on reaching limit: " << 
ex.what());
+const std::string info = Poco::format(PAYLOAD_INFO_LIMIT_REACHED, 
LOOLWSD::MaxDocuments, LOOLWSD::MaxConnections);
+LOG_INF("Sending client 'limitreached' message: " << info);
+
+try
+{
+Util::alertAllUsers(info);
+}
+catch (const std::exception& ex)
+{
+LOG_ERR("Error while shuting down socket on reaching limit: " << 
ex.what());
+}
 }
 }
 
-
 /// Internal implementation to alert all clients
 /// connected to any document.
 void alertAllUsersInternal(const std::string& msg)
@@ -250,6 +251,24 @@ void alertAllUsersInternal(const std::string& msg)
 docBroker->addCallback([msg, docBroker](){ 
docBroker->alertAllUsers(msg); });
 }
 }
+
+static void checkDiskSpaceAndWarnClients(const bool cacheLastCheck)
+{
+try
+{
+const std::string fs = 
FileUtil::checkDiskSpaceOnRegisteredFileSystems(cacheLastCheck);
+if (!fs.empty())
+{
+LOG_WRN("File system of [" << fs << "] is dangerously low on disk 
space.");
+alertAllUsersInternal("error: cmd=internal kind=diskfull");
+}
+}
+catch (const std::exception& exc)
+{
+LOG_WRN("Exception while checking disk-space and warning clients: " << 
exc.what());
+}
+}
+
 }
 
 /// Remove dead and idle DocBrokers.
@@ -300,12 +319,7 @@ static int forkChildren(const int number)
 
 if (number > 0)
 {
-const std::string fs = 
FileUtil::checkDiskSpaceOnRegisteredFileSystems(false);
-if (!fs.empty())
-{
-LOG_WRN("File system of " << fs << " dangerously low on disk 
space");
-alertAllUsersInternal("error: cmd=internal kind=diskfull");
-}
+checkDiskSpaceAndWarnClients(false);
 
 #ifdef KIT_IN_PROCESS
 forkLibreOfficeKit(LOOLWSD::ChildRoot, LOOLWSD::SysTemplate, 
LOOLWSD::LoTemplate, LO_JAIL_SUBPATH, number);
@@ -1514,23 +1528,6 @@ static std::shared_ptr 
createNewClientSession(const WebSocketHand
 const std::string statusReady = "statusindicator: ready";
 LOG_TRC("Sending to Client [" << statusReady << "].");
 ws->sendMessage(statusReady);
-
-const std::string fs = 
FileUtil::checkDiskSpaceOnRegisteredFileSystems();
-if (!fs.empty())
-{
-LOG_WRN("File system of [" << fs << "] is dangerously low on 
disk space.");
-const std::string diskfullMsg = "error: cmd=internal 
kind=diskfull";
-// Alert all existing sessions
-Util::alertAllUsers(diskfullMsg);
-ws->sendMessage(diskfullMsg);
-}
-#if !ENABLE_SUPPORT_KEY
-// Users of development versions get just an info when reaching 
max documents or connections
-if (DocBrokers.size() > LOOLWSD::MaxDocuments || 
LOOLWSD::NumConnections >= LOOLWSD::MaxConnections)
-{
-infoLimitReached(ws);
-}
-#endif
 }
 
 // In case of WOPI, if this session is not set as readonly, it might 
be set so
@@ -2332,6 +2329,12 @@ private:
 
 // Add and load the session.

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

2018-06-11 Thread Ashod Nakashian
 wsd/LOOLWSD.cpp |   56 
 1 file changed, 28 insertions(+), 28 deletions(-)

New commits:
commit 93b41638a58b9e36940bc3faaeb9a0fab7d6524a
Author: Ashod Nakashian 
Date:   Fri Feb 23 19:18:24 2018 -0500

wsd: reduce indentation

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

diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index 3bc6d73e6..a66d0306d 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -2050,37 +2050,36 @@ private:
 format = tokens[3];
 
 bool sent = false;
-if (!fromPath.empty())
+if (!fromPath.empty() && !format.empty())
 {
-if (!format.empty())
-{
-LOG_INF("Conversion request for URI [" << fromPath << 
"].");
+LOG_INF("Conversion request for URI [" << fromPath << "].");
 
-Poco::URI uriPublic = 
DocumentBroker::sanitizeURI(fromPath);
-const std::string docKey = 
DocumentBroker::getDocKey(uriPublic);
+Poco::URI uriPublic = DocumentBroker::sanitizeURI(fromPath);
+const std::string docKey = 
DocumentBroker::getDocKey(uriPublic);
 
-// This lock could become a bottleneck.
-// In that case, we can use a pool and index by publicPath.
-std::unique_lock 
docBrokersLock(DocBrokersMutex);
+// This lock could become a bottleneck.
+// In that case, we can use a pool and index by publicPath.
+std::unique_lock docBrokersLock(DocBrokersMutex);
 
-LOG_DBG("New DocumentBroker for docKey [" << docKey << 
"].");
-auto docBroker = 
std::make_shared(fromPath, uriPublic, docKey, 
LOOLWSD::ChildRoot);
+LOG_DBG("New DocumentBroker for docKey [" << docKey << "].");
+auto docBroker = std::make_shared(fromPath, 
uriPublic, docKey, LOOLWSD::ChildRoot);
 
-cleanupDocBrokers();
+cleanupDocBrokers();
 
-LOG_DBG("New DocumentBroker for docKey [" << docKey << 
"].");
-DocBrokers.emplace(docKey, docBroker);
-LOG_TRC("Have " << DocBrokers.size() << " DocBrokers after 
inserting [" << docKey << "].");
+LOG_DBG("New DocumentBroker for docKey [" << docKey << "].");
+DocBrokers.emplace(docKey, docBroker);
+LOG_TRC("Have " << DocBrokers.size() << " DocBrokers after 
inserting [" << docKey << "].");
 
-// Load the document.
-// TODO: Move to DocumentBroker.
-const bool isReadOnly = true;
-std::shared_ptr clientSession = 
createNewClientSession(nullptr, _id, uriPublic, docBroker, isReadOnly);
-if (clientSession)
+// Load the document.
+// TODO: Move to DocumentBroker.
+const bool isReadOnly = true;
+std::shared_ptr clientSession = 
createNewClientSession(nullptr, _id, uriPublic, docBroker, isReadOnly);
+if (clientSession)
+{
+disposition.setMove([docBroker, clientSession, format]
+(const std::shared_ptr 
)
 {
-disposition.setMove([docBroker, clientSession, format]
-(const std::shared_ptr 
)
-{ // Perform all of this after removing the socket
+// Perform all of this after removing the socket
 
 // Make sure the thread is running before adding 
callback.
 docBroker->startThread();
@@ -2118,13 +2117,12 @@ private:
 std::vector saveasRequest(saveas.begin(), 
saveas.end());
 clientSession->handleMessage(true, WSOpCode::Text, 
saveasRequest);
 });
-});
+});
 
-sent = true;
-}
-else
-LOG_WRN("Failed to create Client Session with id [" << 
_id << "] on docKey [" << docKey << "].");
+sent = true;
 }
+else
+LOG_WRN("Failed to create Client Session with id [" << _id 
<< "] on docKey [" << docKey << "].");
 }
 
 if (!sent)
@@ -2729,11 +2727,13 @@ int LOOLWSD::innerMain()
 LOG_FTL("Missing --systemplate option");
 throw MissingOptionException("systemplate");
 }
+
 if (LoTemplate.empty())
 {
 LOG_FTL("Missing --lotemplate option");
 throw 

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

2018-05-18 Thread Safir Depo
 wsd/LOOLWSD.cpp |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit f6c7df1d0da2915f1faabd4959f92d496ec352e4
Author: Safir Depo 
Date:   Mon May 14 16:36:03 2018 +0300

bugfix for commit:910ae80-'wsd: to filter clientAddress before POST action.'

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

diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index 7004cf795..4ffd8c9df 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -1739,7 +1739,7 @@ public:
 // Parse the host allow settings.
 for (size_t i = 0; ; ++i)
 {
-const std::string path = "post_allow.host[" + 
std::to_string(i) + "]";
+const std::string path = "net.post_allow.host[" + 
std::to_string(i) + "]";
 const auto host = app.config().getString(path, "");
 if (!host.empty())
 {
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2018-04-29 Thread Henry Castro
 wsd/LOOLWSD.cpp |4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

New commits:
commit 921527757687717ab89451dc5e6d76dcbdac9849
Author: Henry Castro 
Date:   Sun Apr 29 21:02:50 2018 -0400

wsd: simplify to use the DEBUG_ABSSRCDIR preprocessing symbol

Change-Id: If71f6c831064482a97069a64eb1d05d8a3c739b4

diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index 5249e2880..d74e3465f 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -531,14 +531,12 @@ inline std::string getLaunchBase(const std::string 
)
 
 inline std::string getLaunchURI(const std::string )
 {
-const std::string aAbsTopSrcDir = 
Poco::Path(Application::instance().commandPath()).parent().toString();
-
 std::ostringstream oss;
 
 oss << getLaunchBase("");
 oss << LOOLWSD_TEST_LOLEAFLET_UI;
 oss << "?file_path=file://";
-oss << Poco::Path(aAbsTopSrcDir).absolute().toString();
+oss << DEBUG_ABSSRCDIR "/";
 oss << document;
 
 return oss.str();
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2018-03-15 Thread Michael Meeks
 wsd/LOOLWSD.cpp |8 +++-
 1 file changed, 3 insertions(+), 5 deletions(-)

New commits:
commit 18108dfa89d7064460f5c21e5dc79747f6cac239
Author: Michael Meeks 
Date:   Thu Mar 15 19:17:17 2018 +

Help OSL's nlsupport with a UTF-8 locale for everyone.

Change-Id: I98557e3134b436b6360129dfd6d16bba811cd864

diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index 47a63f428..5a11ea11d 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -2726,11 +2726,9 @@ int LOOLWSD::innerMain()
 
 initializeSSL();
 
-char* locale = setlocale(LC_ALL, nullptr);
-if (locale == nullptr || std::strcmp(locale, "C") == 0)
-{
-setlocale(LC_ALL, "en_US.utf8");
-}
+// Force a uniform UTF-8 locale for ourselves & our children.
+::setenv("LC_ALL", "en_US.UTF-8", 1);
+setlocale(LC_ALL, "en_US.UTF-8");
 
 if (access(Cache.c_str(), R_OK | W_OK | X_OK) != 0)
 {
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2018-02-26 Thread Miklos Vajna
 wsd/LOOLWSD.cpp |2 ++
 1 file changed, 2 insertions(+)

New commits:
commit 56fd92b4eb3fd27d8b9b09753927e425cd510c11
Author: Miklos Vajna 
Date:   Mon Feb 26 16:08:36 2018 +0100

fix -Werror,-Wunused-function

Change-Id: Idb339471edf9f80f779b50a124098ab056d1a2fc

diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index c25241a9..47a63f42 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -195,6 +195,7 @@ static int careerSpanMs = 0;
 namespace
 {
 
+#if ENABLE_SUPPORT_KEY
 inline void shutdownLimitReached(WebSocketHandler& ws)
 {
 const std::string error = Poco::format(PAYLOAD_UNAVAILABLE_LIMIT_REACHED, 
LOOLWSD::MaxDocuments, LOOLWSD::MaxConnections);
@@ -213,6 +214,7 @@ inline void shutdownLimitReached(WebSocketHandler& ws)
 LOG_ERR("Error while shuting down socket on reaching limit: " << 
ex.what());
 }
 }
+#endif
 
 inline void infoLimitReached(const WebSocketHandler* ws)
 {
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2018-02-08 Thread Pranav Kant
 wsd/LOOLWSD.cpp |   16 ++--
 1 file changed, 14 insertions(+), 2 deletions(-)

New commits:
commit f246f50b9e5b36daa47e35e42eac34a1ae391c2c
Author: Pranav Kant 
Date:   Thu Feb 8 17:04:55 2018 +0530

Don't try different ports unless we are testing

Change-Id: Ideb6b6ccb64f708bf4621cfc92c5836a0fd3b511

diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index 9c598725..5ae13552 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -2565,6 +2565,7 @@ private:
 std::shared_ptr socket = getServerSocket(
 ServerSocket::Type::Local, port, PrisonerPoll, factory);
 
+#ifdef BUILDING_TESTS
 // If we fail, try the next 100 ports.
 for (int i = 0; i < 100 && !socket; ++i)
 {
@@ -2573,10 +2574,11 @@ private:
 socket = getServerSocket(
 ServerSocket::Type::Local, port, PrisonerPoll, factory);
 }
+#endif
 
-if (!UnitWSD::isUnitTesting() && !socket)
+if (!socket)
 {
-LOG_FTL("Failed to listen on Prisoner port (" <<
+LOG_FTL("Failed to listen on Prisoner port(s) (" <<
 MasterPortNumber << '-' << port << "). Exiting.");
 _exit(Application::EXIT_SOFTWARE);
 }
@@ -2598,8 +2600,10 @@ private:
 #endif
 factory = std::make_shared();
 
+
 std::shared_ptr socket = getServerSocket(
 ServerSocket::Type::Public, port, WebServerPoll, factory);
+#ifdef BUILDLING_TESTS
 while (!socket)
 {
 ++port;
@@ -2607,6 +2611,14 @@ private:
 socket = getServerSocket(
 ServerSocket::Type::Public, port, WebServerPoll, factory);
 }
+#endif
+
+if (!socket)
+{
+LOG_FTL("Failed to listen on Server port(s) (" <<
+ClientPortNumber << '-' << port << "). Exiting.");
+_exit(Application::EXIT_SOFTWARE);
+}
 
 ClientPortNumber = port;
 LOG_INF("Listening to client connections on port " << port);
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2018-02-05 Thread Miklos Vajna
 wsd/LOOLWSD.cpp |4 
 1 file changed, 4 deletions(-)

New commits:
commit 0a2df21501e66c35aeb7ae721ec9bdbaa04e198f
Author: Miklos Vajna 
Date:   Mon Feb 5 16:45:23 2018 +0100

wsd: remove unused using declarations in LOOLWSD

Change-Id: I6b656a1446b015430068e4b172cf98fe746f26d1

diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index 34482638..6b6696d8 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -134,11 +134,7 @@ using Poco::Net::HTTPResponse;
 using Poco::Net::MessageHeader;
 using Poco::Net::NameValueCollection;
 using Poco::Net::PartHandler;
-using Poco::Net::SocketAddress;
 using Poco::Path;
-#ifndef KIT_IN_PROCESS
-using Poco::Pipe;
-#endif
 using Poco::Process;
 using Poco::StreamCopier;
 using Poco::StringTokenizer;
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2018-01-26 Thread Pranav Kant
 wsd/LOOLWSD.cpp |4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

New commits:
commit 9ea81e792109b394713e71a5b72aa7f21a17755d
Author: Pranav Kant 
Date:   Fri Jan 26 20:10:36 2018 +0530

wsd: Update client port number if default is unavailable

And print that on the console so that user knows what port the current
wsd instance is using.

Change-Id: I68fb7d23f46df4ad56ba444735b2888c410f7bd5

diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index ca0ca6a5..13ae0298 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -2587,6 +2587,7 @@ private:
 _exit(Application::EXIT_SOFTWARE);
 }
 
+MasterPortNumber = port;
 LOG_INF("Listening to prisoner connections on port " << port);
 return socket;
 }
@@ -2613,6 +2614,7 @@ private:
 ServerSocket::Type::Public, port, WebServerPoll, factory);
 }
 
+ClientPortNumber = port;
 LOG_INF("Listening to client connections on port " << port);
 return socket;
 }
@@ -2751,7 +2753,7 @@ int LOOLWSD::innerMain()
 /// The main-poll does next to nothing:
 SocketPoll mainWait("main");
 #if ENABLE_DEBUG
-std::cerr << "Ready to accept connections.\n" << std::endl;
+std::cerr << "Ready to accept connections on port " << ClientPortNumber << 
 ".\n" << std::endl;
 #endif
 
 const auto startStamp = std::chrono::steady_clock::now();
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2018-01-24 Thread Aron Budea
 wsd/LOOLWSD.cpp |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit 8f2477816bef369e303b9160b04d16058914d5e2
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/44495
Reviewed-by: Aron Budea 
Tested-by: Aron Budea 

diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index 88b6f805..ca0ca6a5 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -2721,7 +2721,7 @@ int LOOLWSD::innerMain()
 }
 else
 {
-const auto timeoutMs = CHILD_TIMEOUT_MS * (LOOLWSD::NoCapsForKit ? 
150 : 10);
+const auto timeoutMs = CHILD_TIMEOUT_MS * (LOOLWSD::NoCapsForKit ? 
150 : 50);
 const auto timeout = std::chrono::milliseconds(timeoutMs);
 LOG_TRC("Waiting for a new child for a max of " << timeoutMs << " 
ms.");
 if (!NewChildrenCV.wait_for(lock, timeout, []() { return 
!NewChildren.empty(); }))
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2018-01-06 Thread Ashod Nakashian
 wsd/LOOLWSD.cpp |3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

New commits:
commit 37593072eba1d59073e22cbdeea8928cfdac344b
Author: Ashod Nakashian 
Date:   Mon Jan 1 16:57:46 2018 -0500

wsd: log some config values for reference

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

diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index 760d74ad..99174cca 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -328,7 +328,6 @@ static bool cleanupChildren()
 }
 
 /// Decides how many children need spawning and spanws.
-/// When force is true, no check of elapsed time since last request is done.
 /// Returns the number of children requested to spawn,
 /// -1 for error.
 static int rebalanceChildren(int balance)
@@ -792,12 +791,14 @@ void LOOLWSD::initialize(Application& self)
 LOG_WRN("Invalid num_prespawn_children in config (" << 
NumPreSpawnedChildren << "). Resetting to 1.");
 NumPreSpawnedChildren = 1;
 }
+LOG_INF("NumPreSpawnedChildren set to " << NumPreSpawnedChildren << ".");
 
 const auto maxConcurrency = getConfigValue(conf, 
"per_document.max_concurrency", 4);
 if (maxConcurrency > 0)
 {
 setenv("MAX_CONCURRENCY", std::to_string(maxConcurrency).c_str(), 1);
 }
+LOG_INF("MAX_CONCURRENCY set to " << maxConcurrency << ".");
 
 // Otherwise we profile the soft-device at jail creation time.
 setenv("SAL_DISABLE_OPENCL", "true", 1);
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2017-11-29 Thread Jan Holesovsky
 wsd/LOOLWSD.cpp |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit 5032529cb989b04575686c9c6eea1d15b556210e
Author: Jan Holesovsky 
Date:   Wed Nov 29 20:05:28 2017 +0100

Don't crash when ssl.cipher_list is not present in loolwsd.xml.

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

diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index 102670e7..622396f7 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -927,7 +927,7 @@ void LOOLWSD::initializeSSL()
 const auto ssl_ca_file_path = getPathFromConfig("ssl.ca_file_path");
 LOG_INF("SSL CA file: " << ssl_ca_file_path);
 
-const auto ssl_cipher_list = getPathFromConfig("ssl.cipher_list");
+const auto ssl_cipher_list = config().getString("ssl.cipher_list", "");
 LOG_INF("SSL Cipher list: " << ssl_cipher_list);
 
 #if ENABLE_SSL
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2017-11-13 Thread Tor Lillqvist
 wsd/LOOLWSD.cpp |1 -
 1 file changed, 1 deletion(-)

New commits:
commit 0df65d21104e1c4a2717c7aea825e9207bcca1ed
Author: Tor Lillqvist 
Date:   Mon Nov 13 23:50:29 2017 +0200

Bin accidental debugging printout leftover

Change-Id: I06f21d3facc39fcbf35a3516bb48136f8660a10f

diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index f73f81f3..7ff87b79 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -705,7 +705,6 @@ void LOOLWSD::initialize(Application& self)
 if (configFile.length() > 4 && 
strcasecmp(configFile.substr(configFile.length() - 4).data(), ".xml") == 0)
 {
 const std::string fullFileName = dir.path() + "/" + configFile;
-std::cerr << "Trying '" << fullFileName << "'" << std::endl;
 PluginConfigurations.insert(new 
XMLConfiguration(fullFileName));
 }
 }
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

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

New commits:
commit c0fcd071d74c5c693f055c0bebd14404168f49b8
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 
(cherry picked from commit 2d2398aa06c66d0a79178becf90b28fdcc20bdfd)
Reviewed-on: https://gerrit.libreoffice.org/43171
Reviewed-by: Jan Holesovsky 
Tested-by: Jan Holesovsky 

diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index 3d41d0c9..f6537efc 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -637,8 +637,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: wsd/LOOLWSD.cpp

2017-10-03 Thread Pranav Kant
 wsd/LOOLWSD.cpp |   30 --
 1 file changed, 20 insertions(+), 10 deletions(-)

New commits:
commit 3008342c5752183bcd447cee5af7c4e947e9abb8
Author: Pranav Kant 
Date:   Tue Oct 3 13:45:29 2017 +0530

Don't kill the process when debugging

Assume that when SLEEPFORDEBUGGER or SLEEPKITFORDEBUGGER is mentioned,
loolwsd is being debugged. In that case, don't set any timeout to exit
before first child is forked.

Change-Id: I2527f02187d8452ef6bebb70e1d750b5e796c4b6

diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index 377e890f..3d41d0c9 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -2595,18 +2595,28 @@ int LOOLWSD::innerMain()
 
 #ifndef KIT_IN_PROCESS
 {
+// Make sure we have at least one child before moving forward.
 std::unique_lock lock(NewChildrenMutex);
-
-const auto timeoutMs = 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.");
-if (!NewChildrenCV.wait_for(lock, timeout, []() { return 
!NewChildren.empty(); }))
+// If we are debugging, it's not uncommon to wait for several minutes 
before first
+// child is born. Don't use an expiry timeout in that case.
+const bool debugging = std::getenv("SLEEPFORDEBUGGER") || 
std::getenv("SLEEPKITFORDEBUGGER");
+if (debugging)
+{
+LOG_DBG("Waiting for new child without timeout.");
+NewChildrenCV.wait(lock, []() { return !NewChildren.empty(); });
+}
+else
 {
-const auto msg = "Failed to fork child processes.";
-LOG_FTL(msg);
-std::cerr << "FATAL: " << msg << std::endl;
-throw std::runtime_error(msg);
+const auto timeoutMs = CHILD_TIMEOUT_MS * (LOOLWSD::NoCapsForKit ? 
150 : 10);
+const auto timeout = std::chrono::milliseconds(timeoutMs);
+LOG_TRC("Waiting for a new child for a max of " << timeoutMs << " 
ms.");
+if (!NewChildrenCV.wait_for(lock, timeout, []() { return 
!NewChildren.empty(); }))
+{
+const auto msg = "Failed to fork child processes.";
+LOG_FTL(msg);
+std::cerr << "FATAL: " << msg << std::endl;
+throw std::runtime_error(msg);
+}
 }
 
 // Check we have at least one.
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2017-09-17 Thread Henry Castro
 wsd/LOOLWSD.cpp |1 +
 1 file changed, 1 insertion(+)

New commits:
commit bccdd8d4d7c84e4992c16f75bc3be70c7143b7a0
Author: Henry Castro 
Date:   Sun Sep 17 10:33:06 2017 -0400

wsd: notify when the document is disconnected

Change-Id: I36e6df3c576ff0f02d3b059c2f1db4226d527b49

diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index 5bcb1613..025bf1cb 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -1439,6 +1439,7 @@ private:
 {
 auto lock = docBroker->getLock();
 docBroker->assertCorrectThread();
+docBroker->setCloseReason("docdisconnected");
 docBroker->stop();
 }
 }
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2017-09-13 Thread Henry Castro
 wsd/LOOLWSD.cpp |3 +++
 1 file changed, 3 insertions(+)

New commits:
commit 2556c2b4418de502a69fac4a2b3267eae91a4c41
Author: Henry Castro 
Date:   Wed Sep 13 17:02:26 2017 -0400

wsd: debug: log when the wsd is ready to accept connections

Change-Id: I56ea17af47bc85f30e74f5e93b94e0f3f3d95be4

diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index c2a452c7..5bcb1613 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -2616,6 +2616,9 @@ int LOOLWSD::innerMain()
 
 /// The main-poll does next to nothing:
 SocketPoll mainWait("main");
+#if ENABLE_DEBUG
+std::cerr << "Ready to accept connections.\n" << std::endl;
+#endif
 
 const auto startStamp = std::chrono::steady_clock::now();
 
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

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

New commits:
commit 92cdab8bf8ea1a72e1745b88e9e31b59560e6f7b
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/40083
Reviewed-by: Jan Holesovsky 
Tested-by: Jan Holesovsky 

diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index 83f34ac5..2852fb7a 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -553,7 +553,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;
 
@@ -2233,8 +2233,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 7ed29e15..86f8dbcb 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: wsd/LOOLWSD.cpp

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

New commits:
commit 3582012333eceb7a9f5fceca28692ef086842fec
Author: Ashod Nakashian 
Date:   Sun Jul 2 22:15:29 2017 -0400

wsd: don't resurrect forkit when shutting down

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

diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index a1272c20..23fbfc81 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -1036,7 +1036,7 @@ bool LOOLWSD::checkAndRestoreForKit()
 if (ForKitProcId == -1)
 {
 // Fire the ForKit process for the first time.
-if (!createForKit())
+if (!ShutdownRequestFlag && !TerminationFlag && !createForKit())
 {
 // Should never fail.
 LOG_FTL("Failed to spawn loolforkit.");
@@ -1065,7 +1065,7 @@ bool LOOLWSD::checkAndRestoreForKit()
 }
 
 // Spawn a new forkit and try to dust it off and resume.
-if (!createForKit())
+if (!ShutdownRequestFlag && !TerminationFlag && 
!createForKit())
 {
 LOG_FTL("Failed to spawn forkit instance. Shutting down.");
 SigUtil::requestShutdown();
@@ -1099,7 +1099,7 @@ bool LOOLWSD::checkAndRestoreForKit()
 {
 // No child processes.
 // Spawn a new forkit and try to dust it off and resume.
-if (!createForKit())
+if (!ShutdownRequestFlag && !TerminationFlag && !createForKit())
 {
 LOG_FTL("Failed to spawn forkit instance. Shutting down.");
 SigUtil::requestShutdown();
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

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

New commits:
commit bc067c7b299ed1299b7fb4546444abf403cb6c5b
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 

diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index 6a62d9d9..eecc6d27 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -1163,6 +1163,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);
@@ -1195,10 +1197,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.
 if (ForKitProcId != -1)
 {
@@ -1236,6 +1234,7 @@ bool LOOLWSD::createForKit()
 Admin::instance().setForKitPid(ForKitProcId);
 Admin::instance().setForKitWritePipe(ForKitWritePipe);
 
+rebalanceChildren(LOOLWSD::NumPreSpawnedChildren - 1);
 return ForKitProcId != -1;
 #endif
 }
@@ -2558,9 +2557,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: wsd/LOOLWSD.cpp

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

New commits:
commit c28992758d1db7f23b477178d93c2b84e9f48c06
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 

diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index 989ff496..6a62d9d9 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -401,9 +401,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: wsd/LOOLWSD.cpp

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

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

wsd: discovery.xml now preprocessed and cached

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

diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index 7c188f17..445027e2 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -1538,6 +1538,11 @@ public:
 {
 }
 
+static void InitStaticFileContentCache()
+{
+StaticFileContentCache["discovery.xml"] = getDiscoveryXML();
+}
+
 private:
 
 /// Set the socket associated with this ResponseClient.
@@ -1752,36 +1757,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;
@@ -1789,7 +1767,7 @@ private:
 << "Last-Modified: " << 
Poco::DateTimeFormatter::format(Poco::Timestamp(), 
Poco::DateTimeFormat::HTTP_FORMAT) << "\r\n"
 << "User-Agent: " << WOPI_AGENT_STRING << "\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;
@@ -2161,12 +2139,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 + '?';
+
+InputSource inputSrc(discoveryPath);
+DOMParser parser;
+AutoPtr docXML = parser.parse();
+AutoPtr listNodes = docXML->getElementsByTagName(action);
+
+for (unsigned long it = 0; it < 

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

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

New commits:
commit 02dbc826318fef5056236d649c6bb6cdb766c03f
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/37716
Reviewed-by: Jan Holesovsky 
Tested-by: Jan Holesovsky 

diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index 40fd9066..1c6c91d6 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -2009,10 +2009,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: wsd/LOOLWSD.cpp

2017-05-08 Thread Michael Meeks
 wsd/LOOLWSD.cpp |2 ++
 1 file changed, 2 insertions(+)

New commits:
commit 1fc176fb05dc6440e005d0e324970d0184162a20
Author: Michael Meeks 
Date:   Mon May 8 13:08:24 2017 +0100

Restore some clean exists during requests - avoiding exceptions.

Change-Id: I89bb82f85341fcd87daf34d19f30031d1c6d1366

diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index 3c0fd06e..a6771996 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -1925,6 +1925,7 @@ private:
 // TODO: We should differentiate between bad request and 
failed conversion.
 throw BadRequestException("Failed to convert and send file.");
 }
+return;
 }
 else if (tokens.count() >= 4 && tokens[3] == "insertfile")
 {
@@ -2031,6 +2032,7 @@ private:
 LOG_ERR("Download file [" << filePath.toString() << "] not 
found.");
 }
 (void)responded;
+return;
 }
 
 throw BadRequestException("Invalid or unknown request.");
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

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

New commits:
commit 3aec6e1227c3d738556a523b2fe999503a10b1b1
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 7f6703f0..3c0fd06e 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -1468,7 +1468,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: wsd/LOOLWSD.cpp wsd/TraceFile.hpp

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

New commits:
commit c31bf89976a14d5dbfb8c4bd012f959284c9344b
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 

diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index 42e3348f..89676207 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -791,7 +791,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);
 }
 
 FileServerRequestHandler::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: wsd/LOOLWSD.cpp

2017-04-27 Thread Michael Meeks
 wsd/LOOLWSD.cpp |7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

New commits:
commit fc8563e778a1ef7db464f35197e23e6e7f7b9bb8
Author: Michael Meeks 
Date:   Wed Apr 26 17:38:50 2017 +0100

Add LOOL_DELAY_SOCKET_MS env. var to simulate latency.

diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index a783b269..51a4691b 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -169,7 +169,7 @@ int MasterPortNumber = DEFAULT_MASTER_PORT_NUMBER;
 static bool DisplayVersion = false;
 
 /// Funky latency simulation basic delay (ms)
-static int SimulatedLatencyMs = 0; // 150;
+static int SimulatedLatencyMs = 0;
 
 // Tracks the set of prisoners / children waiting to be used.
 static std::mutex NewChildrenMutex;
@@ -987,6 +987,10 @@ void LOOLWSD::handleOption(const std::string& optionName,
 static const char* masterPort = std::getenv("LOOL_TEST_MASTER_PORT");
 if (masterPort)
 MasterPortNumber = std::stoi(masterPort);
+
+static const char* latencyMs = std::getenv("LOOL_DELAY_SOCKET_MS");
+if (latencyMs)
+SimulatedLatencyMs = std::stoi(latencyMs);
 #endif
 
 #ifdef FUZZER
@@ -1615,6 +1619,7 @@ private:
 Admin::instance().insertNewSocket(moveSocket);
 });
 }
+
 }
 // Client post and websocket connections
 else if ((request.getMethod() == HTTPRequest::HTTP_GET ||
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

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

New commits:
commit 15e13e58f64f6c9f6e5be706c53916649fd73257
Author: Ashod Nakashian 
Date:   Thu Apr 20 23:11:07 2017 -0400

wsd: clear the socket buffer only after processing the request

Because POST requests need to consume the complete
request message, we shouldn't clear the buffer
before handling the POST request.

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

diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index d109e5d2..a0529380 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -1579,10 +1579,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)
 {
@@ -1668,6 +1664,9 @@ private:
 LOOLProtocol::getAbbreviatedMessage(in) << "]: " << 
exc.what());
 }
 
+// if we succeeded - remove the request from our input buffer
+// we expect one request per socket
+in.erase(in.begin(), itBody);
 return socketOwnership;
 }
 
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


  1   2   >