-
-
Notifications
You must be signed in to change notification settings - Fork 12
PosixSemaphore blocks when there is no space left on device. #28
Copy link
Copy link
Closed
Description
The following code:
$semaphore = PosixSemaphore::create(1, permissions: 0600);will block the current thread forever if there is "no space left on device".
the reason for this seems to be coming from here:
Lines 224 to 230 in 375ef5b
| \set_error_handler(static function (int $errno, string $errstr): bool { | |
| if (\str_contains($errstr, 'Failed for key')) { | |
| return true; | |
| } | |
| throw new SyncException('Failed to create semaphore: ' . $errstr, $errno); | |
| }); |
the error message for when max queue ids is reached is msg_get_queue(): Failed for key 0x00000000: No space left on device ( replacing 0x00000000 with the currently being tested id ).
which amphp skips in attempt to try another ID.
but there seems to be another problem in this logic:
Lines 232 to 255 in 375ef5b
| try { | |
| $id = self::$nextId; | |
| do { | |
| while (\msg_queue_exists($id)) { | |
| $id = self::$nextId = self::$nextId % self::MAX_ID + 1; | |
| } | |
| /** @psalm-suppress TypeDoesNotContainType */ | |
| $queue = \msg_get_queue($id, $permissions); | |
| /** @psalm-suppress RedundantCondition */ | |
| if ($queue) { | |
| /** @psalm-suppress InvalidPropertyAssignmentValue */ | |
| $this->queue = $queue; | |
| $this->initializer = \getmypid(); | |
| break; | |
| } | |
| ++self::$nextId; | |
| } while (true); | |
| } finally { | |
| \restore_error_handler(); | |
| } |
If an identifier exists, but there is no space left on device, the id will not change, Amphp will keep trying to create the queue for the same ID over and over again.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels