From 9aed188b2429d2cf0d2690e1254d728805c4eab7 Mon Sep 17 00:00:00 2001 From: Niklas Keller Date: Tue, 19 Mar 2024 16:46:48 +0100 Subject: [PATCH] Fix SocketIpcHub::accept if already cancelled Relates to #199. --- src/Ipc/SocketIpcHub.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Ipc/SocketIpcHub.php b/src/Ipc/SocketIpcHub.php index e46e38a..9d5e2be 100644 --- a/src/Ipc/SocketIpcHub.php +++ b/src/Ipc/SocketIpcHub.php @@ -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); });