From 2369ea1d500dc2ecea8e355bc2f5692a0a45cc3c Mon Sep 17 00:00:00 2001 From: Philipp Holzer Date: Thu, 15 Aug 2019 17:55:17 +0200 Subject: [PATCH] Fix Lock-Unlink - Check if .sem file exists before unlinking it - Fixing https://github.com/friendica/friendica/issues/7298#issuecomment-521670482 --- src/Core/Lock/SemaphoreLock.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Core/Lock/SemaphoreLock.php b/src/Core/Lock/SemaphoreLock.php index 75c7284a5f..0f41f9f309 100644 --- a/src/Core/Lock/SemaphoreLock.php +++ b/src/Core/Lock/SemaphoreLock.php @@ -68,8 +68,10 @@ class SemaphoreLock extends Lock if (!empty(self::$semaphore[$key])) { try { - $success = @sem_release(self::$semaphore[$key]) && - unlink(self::keyToFile($key)); + $success = @sem_release(self::$semaphore[$key]); + if (file_exists(self::keyToFile($key)) && $success) { + $success = unlink(self::keyToFile($key)); + } unset(self::$semaphore[$key]); $this->markRelease($key); } catch (\Exception $exception) {