Skip to content

Commit

Permalink
chore(io/tcp/unix): don't ignore pending operations
Browse files Browse the repository at this point in the history
Signed-off-by: azjezz <azjezz@protonmail.com>
  • Loading branch information
azjezz committed Nov 29, 2021
1 parent 95125ee commit f9b1dec
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 21 deletions.
13 changes: 2 additions & 11 deletions src/Psl/IO/Internal/ResourceHandle.php
Original file line number Diff line number Diff line change
Expand Up @@ -169,11 +169,7 @@ static function () use (&$deferred) {
public function writeImmediately(string $bytes): int
{
// there's a pending write operation, wait for it first.
$this->writeDeferred
?->getAwaitable()
->then(static fn() => null, static fn() => null)
->ignore()
->await();
$this->writeDeferred?->getAwaitable()->then(static fn() => null, static fn() => null)->await();

if (!is_resource($this->stream)) {
throw new Exception\AlreadyClosedException('Handle has already been closed.');
Expand Down Expand Up @@ -277,12 +273,7 @@ static function () use (&$deferred) {
public function readImmediately(?int $max_bytes = null): string
{
// there's a pending read operation, wait for it.
$this->readDeferred
?->getAwaitable()
->then(static fn() => null, static fn() => null)
->ignore()
->await()
;
$this->readDeferred?->getAwaitable()->then(static fn() => null, static fn() => null)->await();

if (!is_resource($this->stream)) {
throw new Exception\AlreadyClosedException('Handle has already been closed.');
Expand Down
6 changes: 1 addition & 5 deletions src/Psl/TCP/Server.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,7 @@ public static function create(
*/
public function nextConnection(): SocketInterface
{
$this->deferred
?->getAwaitable()
->then(static fn() => null, static fn() => null)
->ignore()
->await();
$this->deferred?->getAwaitable()->then(static fn() => null, static fn() => null)->await();

if (null === $this->impl) {
throw new Network\Exception\AlreadyStoppedException('Server socket has already been stopped.');
Expand Down
6 changes: 1 addition & 5 deletions src/Psl/Unix/Server.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,7 @@ public static function create(string $file): self
*/
public function nextConnection(): SocketInterface
{
$this->deferred
?->getAwaitable()
->then(static fn() => null, static fn() => null)
->ignore()
->await();
$this->deferred?->getAwaitable()->then(static fn() => null, static fn() => null)->await();

if (null === $this->impl) {
throw new Network\Exception\AlreadyStoppedException('Server socket has already been stopped.');
Expand Down

1 comment on commit f9b1dec

@azjezz
Copy link
Owner Author

@azjezz azjezz commented on f9b1dec Nov 29, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the awaitable is always handled here, so calling ignore has no effect.

Please sign in to comment.