Skip to content

Commit

Permalink
Explicitly close resources, so they don't affect further tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kelunik committed Nov 25, 2021
1 parent 359aa98 commit 2683b2e
Showing 1 changed file with 19 additions and 12 deletions.
31 changes: 19 additions & 12 deletions test/Driver/StreamSelectDriverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,21 +60,28 @@ public function testTooLargeFileDescriptorSet(): void
$this->expectException(\Exception::class);
$this->expectExceptionMessage("You have reached the limits of stream_select(). It has a FD_SETSIZE of 1024, but you have file descriptors numbered at least as high as 2");

$this->start(function (Driver $loop) use ($sockets) {
$loop->delay(0.1, function () {
// here to provide timeout to stream_select, as the warning is only issued after the system call returns
});

foreach ($sockets as [$left, $right]) {
$loop->onReadable($left, function () {
// nothing
try {
$this->start(function (Driver $loop) use ($sockets) {
$loop->delay(0.1, function () {
// here to provide timeout to stream_select, as the warning is only issued after the system call returns
});

$loop->onReadable($right, function () {
// nothing
});
foreach ($sockets as [$left, $right]) {
$loop->onReadable($left, function () {
// nothing
});

$loop->onReadable($right, function () {
// nothing
});
}
});
} finally {
foreach ($sockets as [$left, $right]) {
\fclose($left);
\fclose($right);
}
});
}
}

/**
Expand Down

0 comments on commit 2683b2e

Please sign in to comment.