diff options
author | Matúš Kukan <matus.kukan@collabora.com> | 2014-06-24 17:22:34 +0200 |
---|---|---|
committer | Matúš Kukan <matus.kukan@collabora.com> | 2014-06-24 17:27:30 +0200 |
commit | e07cefb4f7ba39d59d25815e208ed61269079142 (patch) | |
tree | 233b13d8302c81e172259548786b5d6f4f0a30c9 /ucb | |
parent | a595879302e26a616131aa0cab5de31bb287b37d (diff) |
webdav: Do not call into DAVResourceAccess with mutex locked.
This commit cherry-picks 0c3500115c4fd86284a027fc32be704afcf77061
for serf webdav version.
Change-Id: I108b0068cad847bf4947ece5e690f789ef034ae9
Diffstat (limited to 'ucb')
-rw-r--r-- | ucb/source/ucp/webdav/webdavcontent.cxx | 116 |
1 files changed, 64 insertions, 52 deletions
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; } |