Skip to content

Fix closing socket resource before removing from loop #141

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 2 commits into from
Dec 23, 2017

Conversation

clue
Copy link
Member

@clue clue commented Dec 23, 2017

Currently, this component implicitly calls fclose() on the underlying socket resource before actually closing the stream (and removing it from the event loop). This code is in place ever since #99 has been merged, but the error didn't really manifest itself until recently, when reactphp/stream#121 landed.

This issue can easily be reproduced by using latest react/stream with ext-event installed. If you have outgoing data pending on a connection, but the connection is detected to be closed by the remote peer, this would cause an uncaught exception.

This PR ensures we do not call fclose() on the socket resource prior to actually invoking the close logic and removing it from the event loop. I've added some tests to try to highlight this issue to avoid any future regressions.

Note that we've recently introduced a related fix in the underlying event loop via reactphp/event-loop#139. That one ensures the loop will not actually complain about this situation and silently remove the invalid stream resource. Despite this relevant fix, it still makes sense to fix the root cause here.

Fixes reactphp/event-loop#136

@clue clue added the bug label Dec 23, 2017
@clue clue added this to the v0.8.7 milestone Dec 23, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Event::set(): supplied resource is not a valid
3 participants