summaryrefslogtreecommitdiff
path: root/ucb
diff options
context:
space:
mode:
authorMichael Stahl <michael.stahl@allotropia.de>2021-10-25 15:26:55 +0200
committerMichael Stahl <michael.stahl@allotropia.de>2021-11-01 18:59:12 +0100
commit791f94a967560fb36cce06e673b115f3ffc707ae (patch)
treee845f143aa7e780a81893c8356f5f07e13176694 /ucb
parent7cd5647b9d02be7527f78a08d49c742be4c34c34 (diff)
ucb: webdav-curl: remove locks from LockStore after AUTH error
[ reimplement commit 94e4695bcfcb9356d37942c47359b94531ef7b95 ] Change-Id: I15d1a95074dcad3f2c642bb0819741a2b0f734c7 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124216 Tested-by: Michael Stahl <michael.stahl@allotropia.de> Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
Diffstat (limited to 'ucb')
-rw-r--r--ucb/source/ucp/webdav-curl/CurlSession.cxx17
-rw-r--r--ucb/source/ucp/webdav-curl/CurlSession.hxx4
-rw-r--r--ucb/source/ucp/webdav-curl/SerfLockStore.cxx19
3 files changed, 35 insertions, 5 deletions
diff --git a/ucb/source/ucp/webdav-curl/CurlSession.cxx b/ucb/source/ucp/webdav-curl/CurlSession.cxx
index 3fe73b57f873..4c42985190ff 100644
--- a/ucb/source/ucp/webdav-curl/CurlSession.cxx
+++ b/ucb/source/ucp/webdav-curl/CurlSession.cxx
@@ -2064,7 +2064,8 @@ auto CurlSession::UNLOCK(OUString const& rURIReference, DAVRequestEnvironment co
}
auto CurlSession::NonInteractive_LOCK(OUString const& rURI,
- sal_Int32& o_rLastChanceToSendRefreshRequest) -> bool
+ sal_Int32& o_rLastChanceToSendRefreshRequest,
+ bool& o_rIsAuthFailed) -> bool
{
SAL_INFO("ucb.ucp.webdav.curl", "NonInteractive_LOCK: " << rURI);
@@ -2097,6 +2098,20 @@ auto CurlSession::NonInteractive_LOCK(OUString const& rURI,
SAL_INFO("ucb.ucp.webdav.curl", "NonInteractive_LOCK succeeded on " << rURI);
return true;
}
+ catch (DAVException const& rException)
+ {
+ SAL_INFO("ucb.ucp.webdav.curl", "NonInteractive_LOCK failed on " << rURI);
+ switch (rException.getError())
+ {
+ case DAVException::DAV_HTTP_AUTH:
+ case DAVException::DAV_HTTP_NOAUTH:
+ o_rIsAuthFailed = true;
+ break;
+ default:
+ break;
+ }
+ return false;
+ }
catch (...)
{
SAL_INFO("ucb.ucp.webdav.curl", "NonInteractive_LOCK failed on " << rURI);
diff --git a/ucb/source/ucp/webdav-curl/CurlSession.hxx b/ucb/source/ucp/webdav-curl/CurlSession.hxx
index 88496308a947..33288b312051 100644
--- a/ucb/source/ucp/webdav-curl/CurlSession.hxx
+++ b/ucb/source/ucp/webdav-curl/CurlSession.hxx
@@ -127,8 +127,8 @@ public:
virtual auto abort() -> void override;
- auto NonInteractive_LOCK(OUString const& rURI, sal_Int32& o_rLastChanceToSendRefreshRequest)
- -> bool;
+ auto NonInteractive_LOCK(OUString const& rURI, sal_Int32& o_rLastChanceToSendRefreshRequest,
+ bool& o_rIsAuthFailed) -> bool;
auto NonInteractive_UNLOCK(OUString const& rURI) -> void;
};
diff --git a/ucb/source/ucp/webdav-curl/SerfLockStore.cxx b/ucb/source/ucp/webdav-curl/SerfLockStore.cxx
index 93cca865eb1b..ef9534dbe58f 100644
--- a/ucb/source/ucp/webdav-curl/SerfLockStore.cxx
+++ b/ucb/source/ucp/webdav-curl/SerfLockStore.cxx
@@ -135,8 +135,10 @@ void SerfLockStore::stopTicker(osl::ClearableMutexGuard & rGuard)
rGuard.clear();
- if (pTickerThread.is())
+ if (pTickerThread.is() && pTickerThread->getIdentifier() != osl::Thread::getCurrentIdentifier())
+ {
pTickerThread->join(); // without m_aMutex locked (to prevent deadlock)
+ }
}
OUString SerfLockStore::getLockToken(const OUString& rURI)
@@ -238,6 +240,8 @@ void SerfLockStore::refreshLocks()
{
osl::MutexGuard aGuard( m_aMutex );
+ ::std::vector<OUString> authFailedLocks;
+
for ( auto& rLockInfo : m_aLockInfoMap )
{
LockInfo & rInfo = rLockInfo.second;
@@ -251,20 +255,31 @@ void SerfLockStore::refreshLocks()
{
// refresh the lock.
sal_Int32 nlastChanceToSendRefreshRequest = -1;
+ bool isAuthFailed(false);
if (rInfo.m_xSession->NonInteractive_LOCK(
- rLockInfo.first, nlastChanceToSendRefreshRequest))
+ rLockInfo.first, nlastChanceToSendRefreshRequest,
+ isAuthFailed))
{
rInfo.m_nLastChanceToSendRefreshRequest
= nlastChanceToSendRefreshRequest;
}
else
{
+ if (isAuthFailed)
+ {
+ authFailedLocks.push_back(rLockInfo.first);
+ }
// refresh failed. stop auto-refresh.
rInfo.m_nLastChanceToSendRefreshRequest = -1;
}
}
}
}
+
+ for (auto const& rLock : authFailedLocks)
+ {
+ removeLock(rLock);
+ }
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */