summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGiuseppe Castagno <giuseppe.castagno@acca-esse.eu>2015-11-21 20:41:06 +0100
committerMiklos Vajna <vmiklos@collabora.co.uk>2015-12-21 14:12:33 +0000
commite1693595443f0a7b6974c065219b7b474dea2bee (patch)
treef2655a1f52853f2d804dd92d1625e63da32accc4
parentf3f90b6490298fdf79d5f9e19c788f0b69e0818e (diff)
Related tdf#90700 Add configuration for web connection timeout.
Currently the connection timeout is governed by operating system default. LO timeouts will be used in place of the TCP socket operating system ones, only in operating system where this is currently possible. The timeouts to use can be changed in LO configuration: 'Tools > Options > Advanced > Expert Configuration'. Propriety names are ConnectTimeout and ReadTimeout. ConnectTimeout contains the timeout (in seconds) used when making a connection (max 180 s, min 2 s, default 20 s). ReadTimeout contains the timeout (in seconds) used when reading from a socket (max 180 s, min 20 s, default 60 s). Change-Id: Ide69ab137274c3bf71332b6e76666151ecac1f1e Reviewed-on: https://gerrit.libreoffice.org/20195 Reviewed-by: Stephan Bergmann <sbergman@redhat.com> Tested-by: Stephan Bergmann <sbergman@redhat.com> (cherry picked from commit 14220052ef2b8675ee12aad63b0402f023d9760a) Reviewed-on: https://gerrit.libreoffice.org/20742 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Giuseppe Castagno <giuseppe.castagno@acca-esse.eu> Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
-rw-r--r--officecfg/registry/schema/org/openoffice/Inet.xcs12
-rw-r--r--ucb/Library_ucpdav1.mk4
-rw-r--r--ucb/source/ucp/webdav-neon/NeonSession.cxx26
-rw-r--r--ucb/source/ucp/webdav-neon/webdavcontent.cxx6
4 files changed, 44 insertions, 4 deletions
diff --git a/officecfg/registry/schema/org/openoffice/Inet.xcs b/officecfg/registry/schema/org/openoffice/Inet.xcs
index e6c1f7b2a99d..f5dcc6a817ac 100644
--- a/officecfg/registry/schema/org/openoffice/Inet.xcs
+++ b/officecfg/registry/schema/org/openoffice/Inet.xcs
@@ -151,6 +151,18 @@
</maxInclusive>
</constraints>
</prop>
+ <prop oor:name="ConnectTimeout" oor:type="xs:int" oor:nillable="false">
+ <info>
+ <desc>Specifies the timeout when first open a connection to a Web/WebDAV server. Time in seconds. Minimum allowed 5 sec maximum 180 sec.</desc>
+ </info>
+ <value>20</value>
+ </prop>
+ <prop oor:name="ReadTimeout" oor:type="xs:int" oor:nillable="false">
+ <info>
+ <desc>Specifies the timeout when waiting for data from a Web/WebDAV server. Time in seconds. Minimum allowed 20 sec maximum 180 sec.</desc>
+ </info>
+ <value>60</value>
+ </prop>
</group>
</component>
</oor:component-schema>
diff --git a/ucb/Library_ucpdav1.mk b/ucb/Library_ucpdav1.mk
index f6e8a62c514c..37f3c8f0af9c 100644
--- a/ucb/Library_ucpdav1.mk
+++ b/ucb/Library_ucpdav1.mk
@@ -33,6 +33,10 @@ $(eval $(call gb_Library_use_externals,ucpdav1,\
openssl \
))
+$(eval $(call gb_Library_use_custom_headers,ucpdav1,\
+ officecfg/registry \
+))
+
$(eval $(call gb_Library_add_exception_objects,ucpdav1,\
ucb/source/ucp/webdav-neon/ContentProperties \
ucb/source/ucp/webdav-neon/DateTimeHelper \
diff --git a/ucb/source/ucp/webdav-neon/NeonSession.cxx b/ucb/source/ucp/webdav-neon/NeonSession.cxx
index 6cd7c320080a..2c3c60cef9b8 100644
--- a/ucb/source/ucp/webdav-neon/NeonSession.cxx
+++ b/ucb/source/ucp/webdav-neon/NeonSession.cxx
@@ -60,6 +60,7 @@ extern "C" {
#include "LinkSequence.hxx"
#include "UCBDeadPropertyValue.hxx"
+#include <officecfg/Inet.hxx>
#include <com/sun/star/xml/crypto/XSecurityEnvironment.hpp>
#include <com/sun/star/security/XCertificate.hpp>
#include <com/sun/star/security/CertificateValidity.hpp>
@@ -691,6 +692,11 @@ void NeonSession::Init()
if ( bCreateNewSession )
{
+ const sal_Int32 nConnectTimeoutMax = 180;
+ const sal_Int32 nConnectTimeoutMin = 2;
+ const sal_Int32 nReadTimeoutMax = 180;
+ const sal_Int32 nReadTimeoutMin = 20;
+
// @@@ For FTP over HTTP proxy inUserInfo is needed to be able to
// build the complete request URI (including user:pass), but
// currently (0.22.0) neon does not allow to pass the user info
@@ -790,6 +796,26 @@ void NeonSession::Init()
ne_set_server_auth( m_pHttpSession, NeonSession_NeonAuth, this );
ne_set_proxy_auth ( m_pHttpSession, NeonSession_NeonAuth, this );
#endif
+ // set timeout to connect
+ // if connect_timeout is not set, neon returns NE_CONNECT when the TCP socket default
+ // timeout elapses
+ // whith connect_timeout set neon returns NE_TIMEOUT if elapsed when the connection
+ // didn't succeed
+ // grab it from configuration
+ uno::Reference< uno::XComponentContext > rContext = m_xFactory->getComponentContext();
+
+ // set the timeout (in seconds) used when making a connection
+ sal_Int32 nConnectTimeout = officecfg::Inet::Settings::ConnectTimeout::get( rContext );
+ ne_set_connect_timeout( m_pHttpSession,
+ (int) ( std::max( nConnectTimeoutMin,
+ std::min( nConnectTimeout, nConnectTimeoutMax ) ) ) );
+
+ // provides a read time out facility as well
+ // set the timeout (in seconds) used when reading from a socket.
+ sal_Int32 nReadTimeout = officecfg::Inet::Settings::ReadTimeout::get( rContext );
+ ne_set_read_timeout( m_pHttpSession,
+ (int) ( std::max( nReadTimeoutMin,
+ std::min( nReadTimeout, nReadTimeoutMax ) ) ) );
}
}
diff --git a/ucb/source/ucp/webdav-neon/webdavcontent.cxx b/ucb/source/ucp/webdav-neon/webdavcontent.cxx
index 98d56e131bfa..d7fe64451b89 100644
--- a/ucb/source/ucp/webdav-neon/webdavcontent.cxx
+++ b/ucb/source/ucp/webdav-neon/webdavcontent.cxx
@@ -3294,6 +3294,7 @@ uno::Any Content::MapDAVException( const DAVException & e, bool bWrite )
// case DAVException::DAV_HTTP_AUTHPROXY:
// break;
+ case DAVException::DAV_HTTP_TIMEOUT:
case DAVException::DAV_HTTP_CONNECT:
aException <<=
ucb::InteractiveNetworkConnectException(
@@ -3304,10 +3305,6 @@ uno::Any Content::MapDAVException( const DAVException & e, bool bWrite )
break;
// @@@ No matching InteractiveNetwork*Exception
-// case DAVException::DAV_HTTP_TIMEOUT:
-// break;
-
-// @@@ No matching InteractiveNetwork*Exception
// case DAVException::DAV_HTTP_REDIRECT:
// break;
@@ -3378,6 +3375,7 @@ uno::Any Content::MapDAVException( const DAVException & e, bool bWrite )
bool Content::shouldAccessNetworkAfterException( const DAVException & e )
{
if ( ( e.getStatus() == SC_NOT_FOUND ) ||
+ ( e.getError() == DAVException::DAV_HTTP_TIMEOUT ) ||
( e.getError() == DAVException::DAV_HTTP_LOOKUP ) ||
( e.getError() == DAVException::DAV_HTTP_CONNECT ) ||
( e.getError() == DAVException::DAV_HTTP_AUTH ) ||