Fix Lock-Unlink

- Check if .sem file exists before unlinking it
- Fixing https://github.com/friendica/friendica/issues/7298#issuecomment-521670482
This commit is contained in:
Philipp Holzer 2019-08-15 17:55:17 +02:00
parent 48caf55cff
commit 2369ea1d50
No known key found for this signature in database
GPG key ID: D8365C3D36B77D90

View file

@ -68,8 +68,10 @@ class SemaphoreLock extends Lock
if (!empty(self::$semaphore[$key])) { if (!empty(self::$semaphore[$key])) {
try { try {
$success = @sem_release(self::$semaphore[$key]) && $success = @sem_release(self::$semaphore[$key]);
unlink(self::keyToFile($key)); if (file_exists(self::keyToFile($key)) && $success) {
$success = unlink(self::keyToFile($key));
}
unset(self::$semaphore[$key]); unset(self::$semaphore[$key]);
$this->markRelease($key); $this->markRelease($key);
} catch (\Exception $exception) { } catch (\Exception $exception) {