kit/Kit.cpp     |    1 -
 loolwsd.xml.in  |    1 +
 wsd/LOOLWSD.cpp |    1 +
 wsd/Storage.cpp |    8 +++++++-
 wsd/Storage.hpp |   10 +++++++++-
 5 files changed, 18 insertions(+), 3 deletions(-)

New commits:
commit c5f9d605e433701680a533fa20a3390f1e7ff5eb
Author:     Ashod Nakashian <ashod.nakash...@collabora.co.uk>
AuthorDate: Thu Jul 16 10:44:41 2020 -0400
Commit:     Ashod Nakashian <a...@collabora.com>
CommitDate: Tue Aug 11 20:11:14 2020 +0200

    wsd: make outgoing connection timeout configurable
    
    The default Poco connection timeout is 60 seconds,
    which is probably excessive. The current configurable
    default is a more reasonable 30 seconds.
    
    Currently we set this timeout on Storage connections
    going out (i.e. WOPI connections).
    
    Change-Id: Ie80a9141ca9bf721addc74baf94e62e0ad72fdd2
    Reviewed-on: https://gerrit.libreoffice.org/c/online/+/98913
    Tested-by: Jenkins
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>
    Reviewed-by: Ashod Nakashian <a...@collabora.com>

diff --git a/kit/Kit.cpp b/kit/Kit.cpp
index 2ad1c545a..42af4b531 100644
--- a/kit/Kit.cpp
+++ b/kit/Kit.cpp
@@ -43,7 +43,6 @@
 #include <Poco/Exception.h>
 #include <Poco/JSON/Object.h>
 #include <Poco/JSON/Parser.h>
-#include <Poco/Net/HTTPClientSession.h>
 #include <Poco/Net/HTTPRequest.h>
 #include <Poco/Net/HTTPResponse.h>
 #include <Poco/Net/NetException.h>
diff --git a/loolwsd.xml.in b/loolwsd.xml.in
index ceb78992e..f1235d618 100644
--- a/loolwsd.xml.in
+++ b/loolwsd.xml.in
@@ -99,6 +99,7 @@
         <host desc="Ditto, but as IPv4-mapped IPv6 
addresses">::ffff:172\.17\.[0-9]{1,3}\.[0-9]{1,3}</host>
       </post_allow>
       <frame_ancestors desc="Specify who is allowed to embed the LO Online 
iframe (loolwsd and WOPI host are always allowed). Separate multiple hosts by 
space."></frame_ancestors>
+      <connection_timeout_secs desc="Specifies the connection, send, recv 
timeout in seconds for connections initiated by loolwsd (such as WOPI 
connections)." type="int" default="30"></connection_timeout_secs>
     </net>
 
     <ssl desc="SSL settings">
diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index 3756db0fb..806c22a0d 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -928,6 +928,7 @@ void LOOLWSD::initialize(Application& self)
             { "loleaflet_html", "loleaflet.html" },
             { "loleaflet_logging", "false" },
             { "mount_jail_tree", "true" },
+            { "net.connection_timeout_secs", "30" },
             { "net.listen", "any" },
             { "net.proto", "all" },
             { "net.service_root", "" },
diff --git a/wsd/Storage.cpp b/wsd/Storage.cpp
index 08a974d0d..9e3854d99 100644
--- a/wsd/Storage.cpp
+++ b/wsd/Storage.cpp
@@ -422,10 +422,16 @@ Poco::Net::HTTPClientSession* 
StorageBase::getHTTPClientSession(const Poco::URI&
     // We decoupled the Wopi communication from client communication because
     // the Wopi communication must have an independent policy.
     // So, we will use here only Storage settings.
-    return useSSL
+    Poco::Net::HTTPClientSession* session = useSSL
         ? new Poco::Net::HTTPSClientSession(uri.getHost(), uri.getPort(),
                                             
Poco::Net::SSLManager::instance().defaultClientContext())
         : new Poco::Net::HTTPClientSession(uri.getHost(), uri.getPort());
+
+    // Set the timeout to the configured value.
+    static int timeoutSec = 
LOOLWSD::getConfigValue<int>("net.connection_timeout_secs", 30);
+    session->setTimeout(Poco::Timespan(timeoutSec, 0));
+
+    return session;
 }
 
 namespace
diff --git a/wsd/Storage.hpp b/wsd/Storage.hpp
index df1b59e5e..652b9bb17 100644
--- a/wsd/Storage.hpp
+++ b/wsd/Storage.hpp
@@ -17,7 +17,6 @@
 
 #include <Poco/URI.h>
 #include <Poco/Util/Application.h>
-#include <Poco/Net/HTTPClientSession.h>
 #include <Poco/JSON/Object.h>
 
 #include "Auth.hpp"
@@ -26,6 +25,15 @@
 #include "Util.hpp"
 #include <common/Authorization.hpp>
 
+namespace Poco
+{
+namespace Net
+{
+class HTTPClientSession;
+}
+
+} // namespace Poco
+
 /// Represents whether the underlying file is locked
 /// and with what token.
 struct LockContext
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to