Skip to content

ExtUvLoop: Fix reporting connection refused errors - #207

Merged
jsor merged 3 commits into
reactphp:masterfrom
clue-labs:ext-uv-connections
Dec 31, 2019
Merged

ExtUvLoop: Fix reporting connection refused errors#207
jsor merged 3 commits into
reactphp:masterfrom
clue-labs:ext-uv-connections

Conversation

@clue

@clueclue commented Dec 28, 2019

Copy link
Copy Markdown
Member

This PR fixes reporting "connection refused" on affected installation of ExtUvLoop. I have started with adding relevant tests to the test matrix, fixing the underlying issue and included additional tests to run run this on Windows as well.

Resolves#188
Builds on top of #205
Refs #206 to skip a similar problem for the StreamSelectLoop on Windows only.

@clueclue added this to the v1.1.1 milestone Dec 28, 2019
@clue
clueforce-pushed the ext-uv-connections branch 2 times, most recently from 515c6d7 to 255aeaaCompareDecember 28, 2019 18:41
@clue
clueforce-pushed the ext-uv-connections branch from 255aeaa to 527c60aCompareDecember 30, 2019 19:31
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.
@clueclue changed the title [WIP] ExtUvLoop: Fix reporting connection refusedExtUvLoop: Fix reporting connection refusedDec 30, 2019
@clueclue changed the title ExtUvLoop: Fix reporting connection refusedExtUvLoop: Fix reporting connection refused errorsDec 30, 2019
@clue

clue commented Dec 30, 2019

Copy link
Copy Markdown
MemberAuthor

It works! 🎉

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.

For future reference, here's how to install this extension in a sample Docker container and all the commands I've used to debug this issue:

docker run -it -v /home/me/workspace:/workspace --workdir=workspace ubuntu:latest bash
apt update
apt-get install -y software-properties-common
add-apt-repository ppa:ondrej/php -y
apt-get install -y libuv1-dev php-pear php-dev strace
pecl install uv-beta
echo"extension=uv">>"$(php -r 'echo php_ini_loaded_file();')"
php -m
cd /workspace
strace php examples/14-http-client-async.php
php -r 'var_dump((new ReflectionClass("UV"))->getConstants());'
vendor/bin/phpunit

Now let's get this shipped! :shipit:

@clue
clue requested review from WyriHaximus and jsorDecember 30, 2019 19:51

@WyriHaximusWyriHaximus left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

🎉

@jsor
jsor merged commit e79f422 into reactphp:masterDec 31, 2019
@clue
clue deleted the ext-uv-connections branch December 31, 2019 14:13
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ExtUv (libuv) does not report connection refused situation

3 participants

@clue@jsor@WyriHaximus