summaryrefslogtreecommitdiff
path: root/ucb
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2018-09-10 13:18:39 +0100
committerCaolán McNamara <caolanm@redhat.com>2018-09-10 18:20:11 +0200
commitb4ccfe7333345a4338240cbd013170ba4751b3a7 (patch)
tree78d13f01ca9b97508c699f71ffad972ef28daf68 /ucb
parentcbc79e563612e9a2eaf66d1e63f98d5094c09d62 (diff)
wrap GlobalNeonMutex as local static
Change-Id: I8d879877c93ce4d3a8f52fc707f94f2f095227d6 Reviewed-on: https://gerrit.libreoffice.org/60262 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'ucb')
-rw-r--r--ucb/source/ucp/webdav-neon/NeonHeadRequest.cxx2
-rw-r--r--ucb/source/ucp/webdav-neon/NeonPropFindRequest.cxx6
-rw-r--r--ucb/source/ucp/webdav-neon/NeonSession.cxx35
-rw-r--r--ucb/source/ucp/webdav-neon/NeonSession.hxx4
4 files changed, 27 insertions, 20 deletions
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