Skip to content

Commit

Permalink
Fix SocketIpcHub::accept if already cancelled
Browse files Browse the repository at this point in the history
Relates to #199.
  • Loading branch information
kelunik committed Mar 19, 2024
1 parent 9403846 commit 9aed188
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/Ipc/SocketIpcHub.php
Original file line number Diff line number Diff line change
Expand Up @@ -165,9 +165,10 @@ public function accept(string $key, ?Cancellation $cancellation = null): Resourc
$this->queued = true;
}

$this->waitingByKey[$key] = $suspension = EventLoop::getSuspension();

$cancellation = $cancellation ?? new NullCancellation();
$cancellation->throwIfRequested();

$this->waitingByKey[$key] = $suspension = EventLoop::getSuspension();
$cancellationId = $cancellation->subscribe(function (CancelledException $exception) use ($suspension) {
$suspension->throw($exception);
});
Expand Down

0 comments on commit 9aed188

Please sign in to comment.