Kaydet (Commit) 14220052 authored tarafından Giuseppe Castagno's avatar Giuseppe Castagno Kaydeden (comit) Stephan Bergmann

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/20195Reviewed-by: 's avatarStephan Bergmann <sbergman@redhat.com>
Tested-by: 's avatarStephan Bergmann <sbergman@redhat.com>
üst d7e5b95c
...@@ -151,6 +151,18 @@ ...@@ -151,6 +151,18 @@
</maxInclusive> </maxInclusive>
</constraints> </constraints>
</prop> </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> </group>
</component> </component>
</oor:component-schema> </oor:component-schema>
...@@ -33,6 +33,10 @@ $(eval $(call gb_Library_use_externals,ucpdav1,\ ...@@ -33,6 +33,10 @@ $(eval $(call gb_Library_use_externals,ucpdav1,\
openssl \ openssl \
)) ))
$(eval $(call gb_Library_use_custom_headers,ucpdav1,\
officecfg/registry \
))
$(eval $(call gb_Library_add_exception_objects,ucpdav1,\ $(eval $(call gb_Library_add_exception_objects,ucpdav1,\
ucb/source/ucp/webdav-neon/ContentProperties \ ucb/source/ucp/webdav-neon/ContentProperties \
ucb/source/ucp/webdav-neon/DateTimeHelper \ ucb/source/ucp/webdav-neon/DateTimeHelper \
......
...@@ -60,6 +60,7 @@ extern "C" { ...@@ -60,6 +60,7 @@ extern "C" {
#include "LinkSequence.hxx" #include "LinkSequence.hxx"
#include "UCBDeadPropertyValue.hxx" #include "UCBDeadPropertyValue.hxx"
#include <officecfg/Inet.hxx>
#include <com/sun/star/xml/crypto/XSecurityEnvironment.hpp> #include <com/sun/star/xml/crypto/XSecurityEnvironment.hpp>
#include <com/sun/star/security/XCertificate.hpp> #include <com/sun/star/security/XCertificate.hpp>
#include <com/sun/star/security/CertificateValidity.hpp> #include <com/sun/star/security/CertificateValidity.hpp>
...@@ -691,6 +692,11 @@ void NeonSession::Init() ...@@ -691,6 +692,11 @@ void NeonSession::Init()
if ( bCreateNewSession ) 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 // @@@ For FTP over HTTP proxy inUserInfo is needed to be able to
// build the complete request URI (including user:pass), but // build the complete request URI (including user:pass), but
// currently (0.22.0) neon does not allow to pass the user info // currently (0.22.0) neon does not allow to pass the user info
...@@ -790,6 +796,26 @@ void NeonSession::Init() ...@@ -790,6 +796,26 @@ void NeonSession::Init()
ne_set_server_auth( m_pHttpSession, NeonSession_NeonAuth, this ); ne_set_server_auth( m_pHttpSession, NeonSession_NeonAuth, this );
ne_set_proxy_auth ( m_pHttpSession, NeonSession_NeonAuth, this ); ne_set_proxy_auth ( m_pHttpSession, NeonSession_NeonAuth, this );
#endif #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 ) ) ) );
} }
} }
......
...@@ -3294,6 +3294,7 @@ uno::Any Content::MapDAVException( const DAVException & e, bool bWrite ) ...@@ -3294,6 +3294,7 @@ uno::Any Content::MapDAVException( const DAVException & e, bool bWrite )
// case DAVException::DAV_HTTP_AUTHPROXY: // case DAVException::DAV_HTTP_AUTHPROXY:
// break; // break;
case DAVException::DAV_HTTP_TIMEOUT:
case DAVException::DAV_HTTP_CONNECT: case DAVException::DAV_HTTP_CONNECT:
aException <<= aException <<=
ucb::InteractiveNetworkConnectException( ucb::InteractiveNetworkConnectException(
...@@ -3303,10 +3304,6 @@ uno::Any Content::MapDAVException( const DAVException & e, bool bWrite ) ...@@ -3303,10 +3304,6 @@ uno::Any Content::MapDAVException( const DAVException & e, bool bWrite )
e.getData() ); e.getData() );
break; break;
// @@@ No matching InteractiveNetwork*Exception
// case DAVException::DAV_HTTP_TIMEOUT:
// break;
// @@@ No matching InteractiveNetwork*Exception // @@@ No matching InteractiveNetwork*Exception
// case DAVException::DAV_HTTP_REDIRECT: // case DAVException::DAV_HTTP_REDIRECT:
// break; // break;
...@@ -3378,6 +3375,7 @@ uno::Any Content::MapDAVException( const DAVException & e, bool bWrite ) ...@@ -3378,6 +3375,7 @@ uno::Any Content::MapDAVException( const DAVException & e, bool bWrite )
bool Content::shouldAccessNetworkAfterException( const DAVException & e ) bool Content::shouldAccessNetworkAfterException( const DAVException & e )
{ {
if ( ( e.getStatus() == SC_NOT_FOUND ) || if ( ( e.getStatus() == SC_NOT_FOUND ) ||
( e.getError() == DAVException::DAV_HTTP_TIMEOUT ) ||
( e.getError() == DAVException::DAV_HTTP_LOOKUP ) || ( e.getError() == DAVException::DAV_HTTP_LOOKUP ) ||
( e.getError() == DAVException::DAV_HTTP_CONNECT ) || ( e.getError() == DAVException::DAV_HTTP_CONNECT ) ||
( e.getError() == DAVException::DAV_HTTP_AUTH ) || ( e.getError() == DAVException::DAV_HTTP_AUTH ) ||
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment