[Libreoffice-commits] core.git: ucb/source

Jean-Louis Fuchs (via logerrit) logerrit at kemper.freedesktop.org
Wed Apr 29 06:08:10 UTC 2020


 ucb/source/ucp/webdav-neon/NeonSession.cxx |    7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

New commits:
commit 58b84caca87c893ac04f0b1399aeadc839a2f075
Author:     Jean-Louis Fuchs <jean-louis.fuchs at adfinis-sygroup.ch>
AuthorDate: Fri Mar 27 17:27:51 2020 +0100
Commit:     Mike Kaganski <mike.kaganski at collabora.com>
CommitDate: Wed Apr 29 08:07:35 2020 +0200

    tdf#132460 Fix feedback-loop during WebDAV lock refresh
    
    Prevent a feedback-loop, where LibreOffice would request a shorter timeout on
    each refresh.
    
    WebDAV servers do not return the lock-timeout the lock was set up with; they
    have to return the remaining time. There are WebDAV servers that return a lower
    timeout. Two examples [2] [3]. Other servers probably reuse the same timestamp
    for the whole request and are therefore not subject to that problem. (This might
    even be incorrect if the request takes very long.)
    
    Updating the lock-timeout with the value returned by the server decreases the
    timeout until it reaches zero.
    
    LibreOffice request               SERVER response
    LOCK(180)         ->              LOCK(60)
    LOCK(60)          ->              LOCK(59)
    LOCK(59)          ->              LOCK(58)
    ...
    0: no LOCK header ->              FAIL
    
    If we do not update the timeout in NeonSession::LOCK() only the initial setup
    updates the timeout.
    
    LibreOffice request               SERVER response
    LOCK(180)        ->               LOCK(60)
    LOCK(60)         ->               LOCK(59)
    LOCK(60)         ->               LOCK(59)
    ...
    
    It is essential that lastChanceToSendRefreshRequest uses the timeout returned by
    the server; after it calculated the deadline, we reset the timeout.
    
    The maintainer of neon confirmed that the timeout should stay the same after the
    initial setup. [4].
    
    [1] https://tools.ietf.org/html/rfc4918#section-6.6
    [2] https://www.alfresco.com/
    [3] https://github.com/mar10/wsgidav
    [4] https://github.com/notroj/neon/issues/12
    
    Change-Id: Ie76338f7a88f41f47569a62ea6efec8c6f646f50
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/92981
    Tested-by: Jenkins
    Reviewed-by: Mike Kaganski <mike.kaganski at collabora.com>

diff --git a/ucb/source/ucp/webdav-neon/NeonSession.cxx b/ucb/source/ucp/webdav-neon/NeonSession.cxx
index c178c1e90238..8ea1db57e5cb 100644
--- a/ucb/source/ucp/webdav-neon/NeonSession.cxx
+++ b/ucb/source/ucp/webdav-neon/NeonSession.cxx
@@ -1624,6 +1624,10 @@ bool NeonSession::LOCK( NeonLock * pLock,
     TimeValue startCall;
     osl_getSystemTime( &startCall );
 
+    // save the current requested timeout, because ne_lock_refresh uses
+    // pLock->timeout as an out parameter. This prevents a feedback-loop,
+    // where we would request a shorter timeout on each refresh.
+    long timeout = pLock->timeout;
     const int theRetVal = ne_lock_refresh(m_pHttpSession, pLock);
     if (theRetVal == NE_OK)
     {
@@ -1631,7 +1635,6 @@ bool NeonSession::LOCK( NeonLock * pLock,
             = lastChanceToSendRefreshRequest( startCall, pLock->timeout );
 
         SAL_INFO( "ucb.ucp.webdav", "LOCK (refresh) - Lock successfully refreshed." );
-        return true;
     }
     else
     {
@@ -1648,6 +1651,8 @@ bool NeonSession::LOCK( NeonLock * pLock,
         }
         return false;
     }
+    pLock->timeout = timeout;
+    return theRetVal;
 }
 
 void NeonSession::UNLOCK( const OUString & inPath,


More information about the Libreoffice-commits mailing list