1
0
mirror of https://github.com/danog/ipc.git synced 2024-11-26 20:15:05 +01:00

Small bugfix

This commit is contained in:
Daniil Gentili 2021-04-20 16:13:45 +02:00
parent a44e077f2d
commit 62eeba222c
Signed by: danog
GPG Key ID: 8C1BE3B34B230CA7

View File

@ -94,12 +94,11 @@ final class ChannelledSocket implements Channel
if ($this->closed) { if ($this->closed) {
return new Success(); return new Success();
} }
$this->closed = true;
return call(function (): \Generator { return call(function (): \Generator {
yield $this->channel->send(new ChannelCloseReq);
if ($this->reading) { if ($this->reading) {
$this->closePromise = new Deferred; $this->closePromise = new Deferred;
} }
yield $this->channel->send(new ChannelCloseReq);
do { do {
$data = yield ($this->closePromise ? $this->closePromise->promise() : $this->channel->receive()); $data = yield ($this->closePromise ? $this->closePromise->promise() : $this->channel->receive());
if ($this->closePromise) { if ($this->closePromise) {
@ -113,6 +112,7 @@ final class ChannelledSocket implements Channel
} }
} while ($this->state !== self::GOT_ALL_MASK); } while ($this->state !== self::GOT_ALL_MASK);
$this->closed = true;
$this->close(); $this->close();
}); });