Skip to content

Fix reporting refused connections with StreamSelectLoop on Windows #208

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Dec 31, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix reporting refused connections with ExtUvLoop
The underlying `epoll_wait()` reports `EPOLLOUT|EPOLLERR|EPOLLHUP` on
the affected file descriptor, which `ext-uv` emits as an error code
`EBADF` with no events attached. We explicitly re-enable all active
events on this error event to invoke the writable listener for this
condition to match other event loop implementations and successfully
detect this as a refused connection attempt. All tests are now green.
  • Loading branch information
clue committed Dec 30, 2019
commit 6d45a1935111d34f2f39d1490edc45cb2a7f97c7
16 changes: 9 additions & 7 deletions src/ExtUvLoop.php
Original file line number Diff line number Diff line change
Expand Up @@ -294,13 +294,15 @@ private function pollStream($stream)
private function createStreamListener()
{
$callback = function ($event, $status, $events, $stream) {
if (!isset($this->streamEvents[(int) $stream])) {
return;
}

if (($events | 4) === 4) {
// Disconnected
return;
// libuv automatically stops polling on error, re-enable polling to match other loop implementations
if ($status !== 0) {
$this->pollStream($stream);

// libuv may report no events on error, but this should still invoke stream listeners to report closed connections
// re-enable both readable and writable, correct listeners will be checked below anyway
if ($events === 0) {
$events = \UV::READABLE | \UV::WRITABLE;
}
}

if (isset($this->readStreams[(int) $stream]) && ($events & \UV::READABLE)) {
Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy