Skip to content

Commit 7e2f0cc

Browse files
authored
fix: fix posix semaphore blocks thread when there is no space left on device (#29)
1 parent 375ef5b commit 7e2f0cc

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/PosixSemaphore.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -222,17 +222,17 @@ private function init(int $maxLocks, int $permissions): void
222222
}
223223

224224
\set_error_handler(static function (int $errno, string $errstr): bool {
225-
if (\str_contains($errstr, 'Failed for key')) {
225+
if (!\str_contains($errstr, 'No space left on device') && \str_contains($errstr, 'Failed for key')) {
226226
return true;
227227
}
228228

229229
throw new SyncException('Failed to create semaphore: ' . $errstr, $errno);
230230
});
231231

232232
try {
233-
$id = self::$nextId;
234-
235233
do {
234+
$id = self::$nextId;
235+
236236
while (\msg_queue_exists($id)) {
237237
$id = self::$nextId = self::$nextId % self::MAX_ID + 1;
238238
}

0 commit comments

Comments
 (0)