Bug 132460 - WebDav ephemeral lock timeout negotiation has a feedback-loop
Summary: WebDav ephemeral lock timeout negotiation has a feedback-loop
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: framework (show other bugs)
Version:
(earliest affected)
7.0.0.0.alpha0+
Hardware: All All
: medium normal
Assignee: Jean-Louis Fuchs
URL:
Whiteboard: target:7.0.0
Keywords:
Depends on:
Blocks:
 
Reported: 2020-04-27 14:21 UTC by Jean-Louis Fuchs
Modified: 2020-05-11 12:41 UTC (History)
2 users (show)

See Also:
Crash report or crash signature:


Attachments
Fix feedback-loop during WebDAV lock refresh (3.00 KB, patch)
2020-04-27 14:23 UTC, Jean-Louis Fuchs
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jean-Louis Fuchs 2020-04-27 14:21:57 UTC
Description:
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


Steps to Reproduce:
1. webdav-neon/webdavcontent.cxx to use a timeout of 12 seconds

diff --git a/ucb/source/ucp/webdav-neon/webdavcontent.cxx b/ucb/source/ucp/webdav-neon/webdavcontent.cxx
index 3113b3c1f5f1..4a0a6b437fc3 100644
--- a/ucb/source/ucp/webdav-neon/webdavcontent.cxx
+++ b/ucb/source/ucp/webdav-neon/webdavcontent.cxx
@@ -3290,7 +3290,7 @@ void Content::lock(
             ucb::LockType_WRITE,
             ucb::LockDepth_ZERO,
             aOwnerAny,
-            180, // lock timeout in secs
+            12, // lock timeout in secs
             //-1, // infinite lock
             uno::Sequence< OUString >() );

Of course you can reproduce the problem without that patch, but you have to wait very long. (180 * 180 / 2 seconds)

2. Run https://github.com/mar10/wsgidav

3. Connect and save a file

4. Close LibreOffice

5. Load the file and watch the wsgidav log

Actual Results:
The lock-request timeouts decrease.

Expected Results:
The lock-request timeout should stay the same.


Reproducible: Always


User Profile Reset: No



Additional Info:
Also observed on a version of Alfresco. I have no details on that.
Comment 1 Jean-Louis Fuchs 2020-04-27 14:23:53 UTC
Created attachment 159997 [details]
Fix feedback-loop during WebDAV lock refresh
Comment 2 Jean-Louis Fuchs 2020-04-27 14:33:38 UTC
I added a patch to gerrit: https://gerrit.libreoffice.org/c/core/+/92981
Comment 3 Commit Notification 2020-04-29 06:08:14 UTC
Jean-Louis Fuchs committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/58b84caca87c893ac04f0b1399aeadc839a2f075

tdf#132460 Fix feedback-loop during WebDAV lock refresh

It will be available in 7.0.0.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 4 Xisco Faulí 2020-05-11 12:06:53 UTC
Hello Jean-Louis,
Should this issue be closed as RESOLVED FIXED ?
Comment 5 Jean-Louis Fuchs 2020-05-11 12:41:29 UTC
Yes, it is resolved fixed. I forgot that.