ucb/source/ucp/webdav-neon/NeonHeadRequest.cxx | 2 - ucb/source/ucp/webdav-neon/NeonPropFindRequest.cxx | 6 +-- ucb/source/ucp/webdav-neon/NeonSession.cxx | 41 +++++++++++++-------- ucb/source/ucp/webdav-neon/NeonSession.hxx | 4 +- 4 files changed, 33 insertions(+), 20 deletions(-)
New commits: commit b4ccfe7333345a4338240cbd013170ba4751b3a7 Author: Caolán McNamara <caol...@redhat.com> AuthorDate: Mon Sep 10 13:18:39 2018 +0100 Commit: Caolán McNamara <caol...@redhat.com> CommitDate: Mon Sep 10 18:20:11 2018 +0200 wrap GlobalNeonMutex as local static Change-Id: I8d879877c93ce4d3a8f52fc707f94f2f095227d6 Reviewed-on: https://gerrit.libreoffice.org/60262 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caol...@redhat.com> Tested-by: Caolán McNamara <caol...@redhat.com> diff --git a/ucb/source/ucp/webdav-neon/NeonHeadRequest.cxx b/ucb/source/ucp/webdav-neon/NeonHeadRequest.cxx index 89c8c9175d35..824622ec9746 100644 --- a/ucb/source/ucp/webdav-neon/NeonHeadRequest.cxx +++ b/ucb/source/ucp/webdav-neon/NeonHeadRequest.cxx @@ -133,7 +133,7 @@ NeonHeadRequest::NeonHeadRequest( HttpSession * inSession, RTL_TEXTENCODING_UTF8 ).getStr() ); { - osl::Guard< osl::Mutex > theGlobalGuard( aGlobalNeonMutex ); + osl::Guard< osl::Mutex > theGlobalGuard(getGlobalNeonMutex()); nError = ne_request_dispatch( req ); } diff --git a/ucb/source/ucp/webdav-neon/NeonPropFindRequest.cxx b/ucb/source/ucp/webdav-neon/NeonPropFindRequest.cxx index c22aee8727ab..3e25121d28fa 100644 --- a/ucb/source/ucp/webdav-neon/NeonPropFindRequest.cxx +++ b/ucb/source/ucp/webdav-neon/NeonPropFindRequest.cxx @@ -261,7 +261,7 @@ NeonPropFindRequest::NeonPropFindRequest( HttpSession* inSession, thePropNames[ theIndex ].name = nullptr; { - osl::Guard< osl::Mutex > theGlobalGuard( aGlobalNeonMutex ); + osl::Guard< osl::Mutex > theGlobalGuard(getGlobalNeonMutex()); nError = ne_simple_propfind( inSession, inPath, inDepth, @@ -276,7 +276,7 @@ NeonPropFindRequest::NeonPropFindRequest( HttpSession* inSession, else { // ALLPROP - osl::Guard< osl::Mutex > theGlobalGuard( aGlobalNeonMutex ); + osl::Guard< osl::Mutex > theGlobalGuard(getGlobalNeonMutex()); nError = ne_simple_propfind( inSession, inPath, inDepth, @@ -298,7 +298,7 @@ NeonPropFindRequest::NeonPropFindRequest( int & nError ) { { - osl::Guard< osl::Mutex > theGlobalGuard( aGlobalNeonMutex ); + osl::Guard< osl::Mutex > theGlobalGuard(getGlobalNeonMutex()); nError = ne_propnames( inSession, inPath, inDepth, diff --git a/ucb/source/ucp/webdav-neon/NeonSession.cxx b/ucb/source/ucp/webdav-neon/NeonSession.cxx index 38ff0ec7925f..8d5f0c20d509 100644 --- a/ucb/source/ucp/webdav-neon/NeonSession.cxx +++ b/ucb/source/ucp/webdav-neon/NeonSession.cxx @@ -604,15 +604,22 @@ void NeonSession::PreSendRequest(ne_request* req, ne_buffer* headers) } } - -// static members -bool NeonSession::m_bGlobalsInited = false; //See https://bugzilla.redhat.com/show_bug.cgi?id=544619#c4 //neon is threadsafe, but uses gnutls which is only thread-safe //if initialized to be thread-safe. cups, unfortunately, generally //initializes it first, and as non-thread-safe, leaving the entire //stack unsafe -osl::Mutex aGlobalNeonMutex; +namespace webdav_ucp +{ + osl::Mutex& getGlobalNeonMutex() + { + static osl::Mutex aMutex; + return aMutex; + } +} + +// static members +bool NeonSession::m_bGlobalsInited = false; NeonLockStore NeonSession::m_aNeonLockStore; NeonSession::NeonSession( const rtl::Reference< DAVSessionFactory > & rSessionFactory, @@ -638,7 +645,7 @@ NeonSession::~NeonSession( ) if ( m_pHttpSession ) { { - osl::Guard< osl::Mutex > theGlobalGuard( aGlobalNeonMutex ); + osl::Guard< osl::Mutex > theGlobalGuard(getGlobalNeonMutex()); ne_session_destroy( m_pHttpSession ); } m_pHttpSession = nullptr; @@ -662,8 +669,8 @@ void NeonSession::Init() if ( m_pHttpSession == nullptr ) { // Ensure that Neon sockets are initialized - osl::Guard< osl::Mutex > theGlobalGuard( aGlobalNeonMutex ); - if ( !m_bGlobalsInited ) + osl::Guard< osl::Mutex > theGlobalGuard(getGlobalNeonMutex()); + if (!m_bGlobalsInited ) { if ( ne_sock_init() != 0 ) throw DAVException( DAVException::DAV_SESSION_CREATE, @@ -713,7 +720,7 @@ void NeonSession::Init() // new session needed, destroy old first { - osl::Guard< osl::Mutex > theGlobalGuard( aGlobalNeonMutex ); + osl::Guard< osl::Mutex > theGlobalGuard(getGlobalNeonMutex()); ne_session_destroy( m_pHttpSession ); } m_pHttpSession = nullptr; @@ -735,7 +742,7 @@ void NeonSession::Init() // to the session { - osl::Guard< osl::Mutex > theGlobalGuard( aGlobalNeonMutex ); + osl::Guard< osl::Mutex > theGlobalGuard(getGlobalNeonMutex()); m_pHttpSession = ne_session_create( OUStringToOString( m_aScheme, RTL_TEXTENCODING_UTF8 ).getStr(), /* theUri.GetUserInfo(), @@ -892,7 +899,7 @@ void NeonSession::OPTIONS( const OUString & inPath, ne_request *req = ne_request_create(m_pHttpSession, "OPTIONS", OUStringToOString( inPath, RTL_TEXTENCODING_UTF8 ).getStr()); { - osl::Guard< osl::Mutex > theGlobalGuard( aGlobalNeonMutex ); + osl::Guard< osl::Mutex > theGlobalGuard(getGlobalNeonMutex()); theRetVal = ne_request_dispatch(req); } @@ -2086,7 +2093,7 @@ int NeonSession::GET( ne_session * sess, = ne_decompress_reader( req, ne_accept_2xx, reader, userdata ); { - osl::Guard< osl::Mutex > theGlobalGuard( aGlobalNeonMutex ); + osl::Guard< osl::Mutex > theGlobalGuard(getGlobalNeonMutex()); ret = ne_request_dispatch( req ); } @@ -2125,7 +2132,7 @@ int NeonSession::GET0( ne_session * sess, int ret; { - osl::Guard< osl::Mutex > theGlobalGuard( aGlobalNeonMutex ); + osl::Guard< osl::Mutex > theGlobalGuard(getGlobalNeonMutex()); ret = ne_request_dispatch( req ); } @@ -2171,7 +2178,7 @@ int NeonSession::PUT( ne_session * sess, ne_set_request_body_buffer( req, buffer, size ); { - osl::Guard< osl::Mutex > theGlobalGuard( aGlobalNeonMutex ); + osl::Guard< osl::Mutex > theGlobalGuard(getGlobalNeonMutex()); ret = ne_request_dispatch( req ); } @@ -2218,7 +2225,7 @@ int NeonSession::POST( ne_session * sess, ne_set_request_body_buffer( req, buffer, strlen( buffer ) ); { - osl::Guard< osl::Mutex > theGlobalGuard( aGlobalNeonMutex ); + osl::Guard< osl::Mutex > theGlobalGuard(getGlobalNeonMutex()); ret = ne_request_dispatch( req ); } diff --git a/ucb/source/ucp/webdav-neon/NeonSession.hxx b/ucb/source/ucp/webdav-neon/NeonSession.hxx index be3ed76a0917..42e01cc61b51 100644 --- a/ucb/source/ucp/webdav-neon/NeonSession.hxx +++ b/ucb/source/ucp/webdav-neon/NeonSession.hxx @@ -278,9 +278,9 @@ private: OUString makeAbsoluteURL( OUString const & rURL ) const; }; -} // namespace webdav_ucp +osl::Mutex& getGlobalNeonMutex(); -extern osl::Mutex aGlobalNeonMutex; +} // namespace webdav_ucp #endif // INCLUDED_UCB_SOURCE_UCP_WEBDAV_NEON_NEONSESSION_HXX commit cbc79e563612e9a2eaf66d1e63f98d5094c09d62 Author: Caolán McNamara <caol...@redhat.com> AuthorDate: Mon Sep 10 12:39:57 2018 +0100 Commit: Caolán McNamara <caol...@redhat.com> CommitDate: Mon Sep 10 18:20:00 2018 +0200 add mutex guard to new methods Change-Id: I4d6ae0622107df6f619f945575687f616f184ccc Reviewed-on: https://gerrit.libreoffice.org/60260 Reviewed-by: Caolán McNamara <caol...@redhat.com> Tested-by: Caolán McNamara <caol...@redhat.com> diff --git a/ucb/source/ucp/webdav-neon/NeonSession.cxx b/ucb/source/ucp/webdav-neon/NeonSession.cxx index c79090cd41db..38ff0ec7925f 100644 --- a/ucb/source/ucp/webdav-neon/NeonSession.cxx +++ b/ucb/source/ucp/webdav-neon/NeonSession.cxx @@ -259,6 +259,8 @@ extern "C" int NeonSession_NeonAuth( void * inUserData, int NeonSession::NeonAuth(const char* inAuthProtocol, const char* inRealm, int attempt, char* inoutUserName, char * inoutPassWord) { + osl::Guard< osl::Mutex > theGuard( m_aMutex ); + /* The callback used to request the username and password in the given * realm. The username and password must be copied into the buffers * which are both of size NE_ABUFSIZ. The 'attempt' parameter is zero @@ -384,6 +386,8 @@ extern "C" int NeonSession_CertificationNotify( void *userdata, int NeonSession::CertificationNotify(const ne_ssl_certificate *cert) { + osl::Guard< osl::Mutex > theGuard( m_aMutex ); + OSL_ASSERT( cert ); uno::Reference< security::XCertificateContainer > xCertificateContainer; @@ -537,6 +541,8 @@ extern "C" void NeonSession_PreSendRequest( ne_request * req, void NeonSession::PreSendRequest(ne_request* req, ne_buffer* headers) { + osl::Guard< osl::Mutex > theGuard( m_aMutex ); + // If there is a proxy server in between, it shall never use // cached data. We always want 'up-to-date' data. ne_buffer_concat( headers, "Pragma: no-cache", EOL, nullptr ); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits