Skip to content

Commit

Permalink
fix: fix posix semaphore blocks thread when there is no space left on…
Browse files Browse the repository at this point in the history
… device (#29)
  • Loading branch information
azjezz authored Aug 3, 2024
1 parent 375ef5b commit 7e2f0cc
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/PosixSemaphore.php
Original file line number Diff line number Diff line change
Expand Up @@ -222,17 +222,17 @@ private function init(int $maxLocks, int $permissions): void
}

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

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

try {
$id = self::$nextId;

do {
$id = self::$nextId;

while (\msg_queue_exists($id)) {
$id = self::$nextId = self::$nextId % self::MAX_ID + 1;
}
Expand Down

0 comments on commit 7e2f0cc

Please sign in to comment.