Skip to content
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

On Windows, fill the events[] array in reverse order. #182

Closed
wants to merge 1 commit into from

Conversation

millert
Copy link
Contributor

@millert millert commented Feb 26, 2018

This helps guarantee the events will be processed in round robin order even when one event is busier than the others. The event loop uses splay_search() to lookup the io_t by the selected event, splaying the tree. As a result, the busy event (usually TAP) will always be first in the events[] array, which usually results in its index being returned by the next call to WSAWaitForMultipleEvents(). By putting the most active event last in events[], other active events get a chance to run.

Otherwise, we may starve events other than the TAP, which is usually at the head. This can cause
missed PING replies.

This helps guarantee the events will be processed in round robin order
even when one event is busier than the others.  The event loop uses
splay_search() to lookup the io_t by the selected event, splaying the
tree.  As a result, the busy event (usually TAP) will always be first in
the events[] array, which usually results in its index being returned
by the next call to WSAWaitForMultipleEvents().  By putting the most
active event last in events[], other active events get a chance to run.

Otherwise, we may starve events other than the
TAP, which is usually at the head.  This can cause missed PING replies.
@millert millert closed this Feb 26, 2018
@millert millert deleted the 1.1-roundrobin branch March 1, 2018 17:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant