Use select to query the uv kqueue#5378
Merged
zcbenz merged 1 commit intoelectron:masterfrom May 4, 2016
Merged
Conversation
This resolves electron#38. I've verified that events still get processed like they should on El Capitan 10.11.3 (15D21).
Contributor
|
This is clever, let's try it! 👍 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This resolves #38. Read the issue for context, but after debugging the problem looks like this:
When a pty is in the uv kqueue, the poll kqueue does not properly clear the event after receiving it. The obvious fix would be to add
EV_CLEARto the event flags so that it is definitely cleared after receiving any event, however this causes a race condition in Darwin. The poll kqueue is signaled before the uv kqueue, resulting in the uv thread running once, seeing no events, and going back to sleep, while simultaneously the poll thread clears its kqueue out. This results in events being delayed until the next event comes in. You can verify that this is a race condition by addingEV_CLEARto the original kevent call and then adding a sleep at the end ofPollEventsThe code is simply waiting for data to be available for reading on the uv kqueue file descriptor, which
selectalso does. I have migrated the Darwin-specific uv polling code to useselectinstead of kqueue.I've verified that events still get processed like they should on El Capitan 10.11.3 (15D21).
Note:
polldoesn't work on kqueues, otherwise I would have used that instead.