diff options
author | Morris Jobke <hey@morrisjobke.de> | 2018-05-07 16:42:26 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-05-07 16:42:26 +0200 |
commit | 7f5567e7583e67d6faac869beb118c179fff0b88 (patch) | |
tree | a79e12bc612d05b70813a6e60e99c1158fa10e70 /lib/private | |
parent | 6d5f4432cd6962234f83ffe30f454c3348cc97f5 (diff) | |
parent | 94c15efad00aa4d85083aff4bcab6fb529646372 (diff) | |
download | nextcloud-server-7f5567e7583e67d6faac869beb118c179fff0b88.tar.gz nextcloud-server-7f5567e7583e67d6faac869beb118c179fff0b88.zip |
Merge pull request #9388 from nextcloud/log-lock-state-on-conflict
Log lock state on conflict
Diffstat (limited to 'lib/private')
-rw-r--r-- | lib/private/Files/Storage/Common.php | 4 | ||||
-rw-r--r-- | lib/private/Lock/MemcacheLockingProvider.php | 19 |
2 files changed, 16 insertions, 7 deletions
diff --git a/lib/private/Files/Storage/Common.php b/lib/private/Files/Storage/Common.php index 0d0f1da2594..b6c82f3a1df 100644 --- a/lib/private/Files/Storage/Common.php +++ b/lib/private/Files/Storage/Common.php @@ -776,9 +776,7 @@ abstract class Common implements Storage, ILockingStorage { try { $provider->changeLock('files/' . md5($this->getId() . '::' . trim($path, '/')), $type); } catch (LockedException $e) { - if ($logger) { - $logger->logException($e); - } + \OC::$server->getLogger()->logException($e); throw $e; } } diff --git a/lib/private/Lock/MemcacheLockingProvider.php b/lib/private/Lock/MemcacheLockingProvider.php index 70ad972b46d..55a82b22781 100644 --- a/lib/private/Lock/MemcacheLockingProvider.php +++ b/lib/private/Lock/MemcacheLockingProvider.php @@ -72,12 +72,12 @@ class MemcacheLockingProvider extends AbstractLockingProvider { public function acquireLock(string $path, int $type) { if ($type === self::LOCK_SHARED) { if (!$this->memcache->inc($path)) { - throw new LockedException($path); + throw new LockedException($path, null, $this->getExistingLockForException($path)); } } else { $this->memcache->add($path, 0); if (!$this->memcache->cas($path, 0, 'exclusive')) { - throw new LockedException($path); + throw new LockedException($path, null, $this->getExistingLockForException($path)); } } $this->setTTL($path); @@ -115,15 +115,26 @@ class MemcacheLockingProvider extends AbstractLockingProvider { public function changeLock(string $path, int $targetType) { if ($targetType === self::LOCK_SHARED) { if (!$this->memcache->cas($path, 'exclusive', 1)) { - throw new LockedException($path); + throw new LockedException($path, null, $this->getExistingLockForException($path)); } } else if ($targetType === self::LOCK_EXCLUSIVE) { // we can only change a shared lock to an exclusive if there's only a single owner of the shared lock if (!$this->memcache->cas($path, 1, 'exclusive')) { - throw new LockedException($path); + throw new LockedException($path, null, $this->getExistingLockForException($path)); } } $this->setTTL($path); $this->markChange($path, $targetType); } + + private function getExistingLockForException($path) { + $existing = $this->memcache->get($path); + if (!$existing) { + return 'none'; + } else if ($existing === 'exclusive') { + return $existing; + } else { + return $existing . ' shared locks'; + } + } } |