From e07cefb4f7ba39d59d25815e208ed61269079142 Mon Sep 17 00:00:00 2001 From: Matúš Kukan Date: Tue, 24 Jun 2014 17:22:34 +0200 Subject: webdav: Do not call into DAVResourceAccess with mutex locked. This commit cherry-picks 0c3500115c4fd86284a027fc32be704afcf77061 for serf webdav version. Change-Id: I108b0068cad847bf4947ece5e690f789ef034ae9 --- ucb/source/ucp/webdav/webdavcontent.cxx | 116 ++++++++++++++++++-------------- 1 file changed, 64 insertions(+), 52 deletions(-) (limited to 'ucb') diff --git a/ucb/source/ucp/webdav/webdavcontent.cxx b/ucb/source/ucp/webdav/webdavcontent.cxx index c91cfc2054fb..faca5653cfa3 100644 --- a/ucb/source/ucp/webdav/webdavcontent.cxx +++ b/ucb/source/ucp/webdav/webdavcontent.cxx @@ -1472,8 +1472,8 @@ uno::Reference< sdbc::XRow > Content::getPropertyValues( } catch ( DAVException const & e ) { - bNetworkAccessAllowed - = shouldAccessNetworkAfterException( e ); + bNetworkAccessAllowed = bNetworkAccessAllowed && + shouldAccessNetworkAfterException( e ); if ( !bNetworkAccessAllowed ) { @@ -3329,66 +3329,78 @@ const Content::ResourceType & Content::getResourceType( bool * networkAccessAllowed ) throw ( uno::Exception ) { - if ( m_eResourceType == UNKNOWN ) { - osl::Guard< osl::Mutex > aGuard( m_aMutex ); + osl::MutexGuard g(m_aMutex); + if (m_eResourceType != UNKNOWN) { + return m_eResourceType; + } + } - ResourceType eResourceType = UNKNOWN; + ResourceType eResourceType = UNKNOWN; - try + try + { + // Try to fetch some frequently used property value, e.g. those + // used when loading documents... along with identifying whether + // this is a DAV resource. + std::vector< DAVResource > resources; + std::vector< OUString > aPropNames; + uno::Sequence< beans::Property > aProperties( 5 ); + aProperties[ 0 ].Name = "IsFolder"; + aProperties[ 1 ].Name = "IsDocument"; + aProperties[ 2 ].Name = "IsReadOnly"; + aProperties[ 3 ].Name = "MediaType"; + aProperties[ 4 ].Name = DAVProperties::SUPPORTEDLOCK; + + ContentProperties::UCBNamesToDAVNames( + aProperties, aPropNames ); + + rResAccess->PROPFIND( + DAVZERO, aPropNames, resources, xEnv ); + + // TODO - is this really only one? + if ( resources.size() == 1 ) { - // Try to fetch some frequently used property value, e.g. those - // used when loading documents... along with identifying whether - // this is a DAV resource. - std::vector< DAVResource > resources; - std::vector< OUString > aPropNames; - uno::Sequence< beans::Property > aProperties( 5 ); - aProperties[ 0 ].Name = "IsFolder"; - aProperties[ 1 ].Name = "IsDocument"; - aProperties[ 2 ].Name = "IsReadOnly"; - aProperties[ 3 ].Name = "MediaType"; - aProperties[ 4 ].Name = DAVProperties::SUPPORTEDLOCK; - - ContentProperties::UCBNamesToDAVNames( - aProperties, aPropNames ); - - rResAccess->PROPFIND( - DAVZERO, aPropNames, resources, xEnv ); - - // TODO - is this really only one? - if ( resources.size() == 1 ) - { - m_xCachedProps.reset( - new CachableContentProperties( resources[ 0 ] ) ); - m_xCachedProps->containsAllNames( - aProperties, m_aFailedPropNames ); - } + osl::MutexGuard g(m_aMutex); + m_xCachedProps.reset( + new CachableContentProperties( resources[ 0 ] ) ); + m_xCachedProps->containsAllNames( + aProperties, m_aFailedPropNames ); + } - eResourceType = DAV; + eResourceType = DAV; + } + catch ( DAVException const & e ) + { + rResAccess->resetUri(); + + if ( e.getStatus() == SC_METHOD_NOT_ALLOWED ) + { + // Status SC_METHOD_NOT_ALLOWED is a safe indicator that the + // resource is NON_DAV + eResourceType = NON_DAV; } - catch ( DAVException const & e ) + else if (networkAccessAllowed != 0) { - rResAccess->resetUri(); - - if ( e.getStatus() == SC_METHOD_NOT_ALLOWED ) - { - // Status SC_METHOD_NOT_ALLOWED is a safe indicator that the - // resource is NON_DAV - eResourceType = NON_DAV; - } - else if (networkAccessAllowed != 0) - { - *networkAccessAllowed = *networkAccessAllowed - && shouldAccessNetworkAfterException(e); - } + *networkAccessAllowed = *networkAccessAllowed + && shouldAccessNetworkAfterException(e); + } - // cancel command execution is case that no user authentication data has been provided. - if ( e.getError() == DAVException::DAV_HTTP_NOAUTH ) - { - cancelCommandExecution( e, uno::Reference< ucb::XCommandEnvironment >() ); - } + // cancel command execution is case that no user authentication data has been provided. + if ( e.getError() == DAVException::DAV_HTTP_NOAUTH ) + { + cancelCommandExecution( e, uno::Reference< ucb::XCommandEnvironment >() ); } + } + + osl::MutexGuard g(m_aMutex); + if (m_eResourceType == UNKNOWN) { m_eResourceType = eResourceType; + } else { + SAL_WARN_IF( + eResourceType != m_eResourceType, "ucb.ucp.webdav", + "different resource types for <" << rResAccess->getURL() << ">: " + << +eResourceType << " vs. " << +m_eResourceType); } return m_eResourceType; } -- cgit v1.2.3