[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-4.2' - 3 commits - ucb/source

Matúš Kukan matus.kukan at collabora.com
Tue Jun 24 10:10:14 PDT 2014


 ucb/source/ucp/webdav-neon/webdavcontent.cxx |    6 +
 ucb/source/ucp/webdav-neon/webdavcontent.hxx |    1 
 ucb/source/ucp/webdav/SerfSession.cxx        |    1 
 ucb/source/ucp/webdav/webdavcontent.cxx      |  128 +++++++++++++++------------
 ucb/source/ucp/webdav/webdavcontent.hxx      |    4 
 5 files changed, 84 insertions(+), 56 deletions(-)

New commits:
commit 0c2e1906b3018ef9ce75920a4f4eb48e34795393
Author: Matúš Kukan <matus.kukan at collabora.com>
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)
    
    Conflicts:
    	ucb/source/ucp/webdav/webdavcontent.cxx
    
    Change-Id: I108b0068cad847bf4947ece5e690f789ef034ae9

diff --git a/ucb/source/ucp/webdav/webdavcontent.cxx b/ucb/source/ucp/webdav/webdavcontent.cxx
index f6de8ae..f053874 100644
--- a/ucb/source/ucp/webdav/webdavcontent.cxx
+++ b/ucb/source/ucp/webdav/webdavcontent.cxx
@@ -1492,8 +1492,8 @@ uno::Reference< sdbc::XRow > Content::getPropertyValues(
                     }
                     catch ( DAVException const & e )
                     {
-                        bNetworkAccessAllowed
-                            = shouldAccessNetworkAfterException( e );
+                        bNetworkAccessAllowed = bNetworkAccessAllowed &&
+                            shouldAccessNetworkAfterException( e );
 
                         if ( !bNetworkAccessAllowed )
                         {
@@ -3367,71 +3367,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
-                = OUString::createFromAscii( "IsFolder" );
-            aProperties[ 1 ].Name
-                = OUString::createFromAscii( "IsDocument" );
-            aProperties[ 2 ].Name
-                = OUString::createFromAscii( "IsReadOnly" );
-            aProperties[ 3 ].Name
-                = OUString::createFromAscii( "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;
 }
commit a794701a672b7fbb092f42124cbf83439a88288e
Author: Matúš Kukan <matus.kukan at collabora.com>
Date:   Mon Jun 23 10:39:49 2014 +0200

    webdav: Do not throw when saving new document.
    
    Propagate information about !shouldAccessNetworkAfterException
    from getResourceType out to getPropertyValues, to avoid further calls
    which would result in cancelCommandExecution, when trying get properties
    of document which does not exist yet, but we want to create it.
    
    This was done in webdav-neon for other reasons as part of
    0c3500115c4fd86284a027fc32be704afcf77061.
    
    (cherry picked from commit 96e23564e95d2ecc5483e55b022c8a4db04d116b)
    
    Conflicts:
    	ucb/source/ucp/webdav/webdavcontent.cxx
    
    Change-Id: Ia434a707d2946a6982075f9bf53904b78dc07a5e

diff --git a/ucb/source/ucp/webdav/webdavcontent.cxx b/ucb/source/ucp/webdav/webdavcontent.cxx
index c1ac9f9..f6de8ae 100644
--- a/ucb/source/ucp/webdav/webdavcontent.cxx
+++ b/ucb/source/ucp/webdav/webdavcontent.cxx
@@ -1399,9 +1399,8 @@ uno::Reference< sdbc::XRow > Content::getPropertyValues(
         /////////////////////////////////////////////////////////////////////
 
         // First, identify whether resource is DAV or not
-        const ResourceType & rType = getResourceType( xEnv, xResAccess );
-
         bool bNetworkAccessAllowed = true;
+        const ResourceType & rType = getResourceType( xEnv, xResAccess, &bNetworkAccessAllowed );
 
         if ( DAV == rType )
         {
@@ -3364,15 +3363,15 @@ Content::getBaseURI( const boost::scoped_ptr< DAVResourceAccess > & rResAccess )
 //=========================================================================
 const Content::ResourceType & Content::getResourceType(
                     const uno::Reference< ucb::XCommandEnvironment >& xEnv,
-                    const boost::scoped_ptr< DAVResourceAccess > & rResAccess )
+                    const boost::scoped_ptr< DAVResourceAccess > & rResAccess,
+                    bool * networkAccessAllowed )
     throw ( uno::Exception )
 {
     if ( m_eResourceType == UNKNOWN )
     {
         osl::Guard< osl::Mutex > aGuard( m_aMutex );
 
-        ResourceType eResourceType;
-        eResourceType = m_eResourceType;
+        ResourceType eResourceType = UNKNOWN;
 
         try
         {
@@ -3420,6 +3419,12 @@ const Content::ResourceType & Content::getResourceType(
                 // resource is NON_DAV
                 eResourceType = NON_DAV;
             }
+            else if (networkAccessAllowed != 0)
+            {
+                *networkAccessAllowed = *networkAccessAllowed
+                    && shouldAccessNetworkAfterException(e);
+            }
+
             // cancel command execution is case that no user authentication data has been provided.
             if ( e.getError() == DAVException::DAV_HTTP_NOAUTH )
             {
diff --git a/ucb/source/ucp/webdav/webdavcontent.hxx b/ucb/source/ucp/webdav/webdavcontent.hxx
index 32801be..b36d88d 100644
--- a/ucb/source/ucp/webdav/webdavcontent.hxx
+++ b/ucb/source/ucp/webdav/webdavcontent.hxx
@@ -133,7 +133,8 @@ private:
     const ResourceType &
     getResourceType( const ::com::sun::star::uno::Reference<
                           ::com::sun::star::ucb::XCommandEnvironment >& xEnv,
-                     const boost::scoped_ptr< DAVResourceAccess > & rResAccess )
+                     const boost::scoped_ptr< DAVResourceAccess > & rResAccess,
+                     bool * networkAccessAllowed = 0 )
         throw ( ::com::sun::star::uno::Exception );
 
     // Command "open"
commit 15dd69fbee91427931243bdd71f8d388280c97f2
Author: Matúš Kukan <matus.kukan at collabora.com>
Date:   Tue Jun 24 16:22:51 2014 +0200

    fdo#72157: webdav: Release WebDAV file lock on document close.
    
    Make it work with both serf and neon version.
    
    Change-Id: I3c74ba57cde19f4417d0229c1c809756e3c5f9f8
    (cherry picked from commit 956d088db5850e9a096bb9abd8b3e446e096f613)

diff --git a/ucb/source/ucp/webdav-neon/webdavcontent.cxx b/ucb/source/ucp/webdav-neon/webdavcontent.cxx
index bff41ad..ce2fcbb 100644
--- a/ucb/source/ucp/webdav-neon/webdavcontent.cxx
+++ b/ucb/source/ucp/webdav-neon/webdavcontent.cxx
@@ -112,6 +112,7 @@ Content::Content(
   m_eResourceType( UNKNOWN ),
   m_pProvider( pProvider ),
   m_bTransient( false ),
+  m_bLocked( false ),
   m_bCollection( false ),
   m_bDidGetOrHead( false )
 {
@@ -144,6 +145,7 @@ Content::Content(
   m_eResourceType( UNKNOWN ),
   m_pProvider( pProvider ),
   m_bTransient( true ),
+  m_bLocked( false ),
   m_bCollection( isCollection ),
   m_bDidGetOrHead( false )
 {
@@ -164,6 +166,8 @@ Content::Content(
 // virtual
 Content::~Content()
 {
+    if (m_bLocked)
+        unlock(uno::Reference< ucb::XCommandEnvironment >());
 }
 
 //=========================================================================
@@ -2818,6 +2822,7 @@ void Content::lock(
             uno::Sequence< OUString >() );
 
         xResAccess->LOCK( aLock, Environment );
+        m_bLocked = true;
 
         {
             osl::Guard< osl::Mutex > aGuard( m_aMutex );
@@ -2847,6 +2852,7 @@ void Content::unlock(
         }
 
         xResAccess->UNLOCK( Environment );
+        m_bLocked = false;
 
         {
             osl::Guard< osl::Mutex > aGuard( m_aMutex );
diff --git a/ucb/source/ucp/webdav-neon/webdavcontent.hxx b/ucb/source/ucp/webdav-neon/webdavcontent.hxx
index f2d378b..ee46d6d 100644
--- a/ucb/source/ucp/webdav-neon/webdavcontent.hxx
+++ b/ucb/source/ucp/webdav-neon/webdavcontent.hxx
@@ -91,6 +91,7 @@ class Content : public ::ucbhelper::ContentImplHelper,
     ResourceType      m_eResourceType;
     ContentProvider*  m_pProvider; // No need for a ref, base class holds object
     bool              m_bTransient;
+    bool              m_bLocked;
     bool              m_bCollection;
     bool              m_bDidGetOrHead;
     std::vector< OUString > m_aFailedPropNames;
diff --git a/ucb/source/ucp/webdav/SerfSession.cxx b/ucb/source/ucp/webdav/SerfSession.cxx
index 938c610..23eb29a 100644
--- a/ucb/source/ucp/webdav/SerfSession.cxx
+++ b/ucb/source/ucp/webdav/SerfSession.cxx
@@ -1068,6 +1068,7 @@ void SerfSession::UNLOCK( const OUString & inPath,
     {
         HandleError( aReqProc );
         SAL_INFO("ucb.ucp.webdav",  "UNLOCK of " << inPath << " succeeded." );
+        apr_environment::AprEnv::getAprEnv()->getSerfLockStore()->removeLock( inPath );
     }
     catch(...)
     {
diff --git a/ucb/source/ucp/webdav/webdavcontent.cxx b/ucb/source/ucp/webdav/webdavcontent.cxx
index 5c9afc2..c1ac9f9 100644
--- a/ucb/source/ucp/webdav/webdavcontent.cxx
+++ b/ucb/source/ucp/webdav/webdavcontent.cxx
@@ -207,6 +207,7 @@ Content::Content(
   m_eResourceType( UNKNOWN ),
   m_pProvider( pProvider ),
   m_bTransient( false ),
+  m_bLocked( false ),
   m_bCollection( false ),
   m_bDidGetOrHead( false )
 {
@@ -239,6 +240,7 @@ Content::Content(
   m_eResourceType( UNKNOWN ),
   m_pProvider( pProvider ),
   m_bTransient( true ),
+  m_bLocked( false ),
   m_bCollection( isCollection ),
   m_bDidGetOrHead( false )
 {
@@ -259,6 +261,8 @@ Content::Content(
 // virtual
 Content::~Content()
 {
+    if (m_bLocked)
+        unlock(uno::Reference< ucb::XCommandEnvironment >());
 }
 
 //=========================================================================
@@ -2983,6 +2987,7 @@ void Content::lock(
             uno::Sequence< OUString >() );
 
         xResAccess->LOCK( aLock, Environment );
+        m_bLocked = true;
 
         {
             osl::Guard< osl::Mutex > aGuard( m_aMutex );
@@ -3010,6 +3015,7 @@ void Content::unlock(
         }
 
         xResAccess->UNLOCK( Environment );
+        m_bLocked = false;
 
         {
             osl::Guard< osl::Mutex > aGuard( m_aMutex );
diff --git a/ucb/source/ucp/webdav/webdavcontent.hxx b/ucb/source/ucp/webdav/webdavcontent.hxx
index 0b10d80..32801be 100644
--- a/ucb/source/ucp/webdav/webdavcontent.hxx
+++ b/ucb/source/ucp/webdav/webdavcontent.hxx
@@ -82,6 +82,7 @@ class Content : public ::ucbhelper::ContentImplHelper,
     ResourceType      m_eResourceType;
     ContentProvider*  m_pProvider; // No need for a ref, base class holds object
     bool              m_bTransient;
+    bool              m_bLocked;
     bool              m_bCollection;
     bool              m_bDidGetOrHead;
     std::vector< OUString > m_aFailedPropNames;


More information about the Libreoffice-commits mailing list