waiter: report WAITER_REMCLOSE correctly #4138
Merged
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.
There seems to be a discrepancy between the epoll and kqueue
implementation. One implementation is not reporting WAITER_REMCLOSE,
while the other implementation is reporting WAITER_REMCLOSE too soon.
epoll:
We sometimes incorrectly report WAITER_ACTION when it is supposed to be
WAITER_REMCLOSE. We can check EPOLLRDHUP before reading 1 byte with MSG_PEEK to
detect WAITER_REMCLOSE. This saves us from a pontential session detour from the
Waiter to a worker thread.
kqueue:
We incorrectly report WAITER_REMCLOSE when there could be more data to be
read from the socket. Change this so that we perform read of 1 byte with
MSG_PEEK to detect closure when EV_EOF is set.
DESCRIPTION:EVFILT_READ:Sockets: