ucb/source/ucp/webdav/webdavcontent.cxx | 120 +++++++++++++++++--------------- ucb/source/ucp/webdav/webdavcontent.hxx | 4 - 2 files changed, 68 insertions(+), 56 deletions(-)
New commits: commit 9f1f7a6bf2fa0aa6ebe2907c38a2e5b56b1dacac Author: Matúš Kukan <[email protected]> Date: Tue Jun 24 17:22:34 2014 +0200 webdav: Do not call into DAVResourceAccess with mutex locked. This commit cherry-picks 0c3500115c4fd86284a027fc32be704afcf77061 for serf webdav version. (cherry picked from commit e07cefb4f7ba39d59d25815e208ed61269079142) Change-Id: I108b0068cad847bf4947ece5e690f789ef034ae9 Reviewed-on: https://gerrit.libreoffice.org/9889 Reviewed-by: Michael Stahl <[email protected]> Tested-by: Michael Stahl <[email protected]> diff --git a/ucb/source/ucp/webdav/webdavcontent.cxx b/ucb/source/ucp/webdav/webdavcontent.cxx index 8cc72bb..99c5e0f 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 ) { @@ -3323,78 +3323,90 @@ Content::getBaseURI( const boost::scoped_ptr< DAVResourceAccess > & rResAccess ) } -const Content::ResourceType & Content::getResourceType( +Content::ResourceType Content::getResourceType( const uno::Reference< ucb::XCommandEnvironment >& xEnv, const boost::scoped_ptr< DAVResourceAccess > & rResAccess, 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; } -const Content::ResourceType & Content::getResourceType( +Content::ResourceType Content::getResourceType( const uno::Reference< ucb::XCommandEnvironment >& xEnv ) throw ( uno::Exception ) { diff --git a/ucb/source/ucp/webdav/webdavcontent.hxx b/ucb/source/ucp/webdav/webdavcontent.hxx index f6e0639..3f6c2cb 100644 --- a/ucb/source/ucp/webdav/webdavcontent.hxx +++ b/ucb/source/ucp/webdav/webdavcontent.hxx @@ -125,12 +125,12 @@ private: const OUString getBaseURI( const boost::scoped_ptr< DAVResourceAccess > & rResAccess ); - const ResourceType & + ResourceType getResourceType( const ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XCommandEnvironment >& xEnv ) throw ( ::com::sun::star::uno::Exception ); - const ResourceType & + ResourceType getResourceType( const ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XCommandEnvironment >& xEnv, const boost::scoped_ptr< DAVResourceAccess > & rResAccess,
_______________________________________________ Libreoffice-commits mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
