]> git.mxchange.org Git - friendica.git/commitdiff
Fix Lock-Unlink
authorPhilipp Holzer <admin+github@philipp.info>
Thu, 15 Aug 2019 15:55:17 +0000 (17:55 +0200)
committerPhilipp Holzer <admin+github@philipp.info>
Thu, 15 Aug 2019 15:55:17 +0000 (17:55 +0200)
- Check if .sem file exists before unlinking it
- Fixing https://github.com/friendica/friendica/issues/7298#issuecomment-521670482

src/Core/Lock/SemaphoreLock.php

index 75c7284a5fd8085c64aba0c485def8bdad92d9da..0f41f9f309556cf7355016044ce7ba85294d3f93 100644 (file)
@@ -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) {