-
-
Notifications
You must be signed in to change notification settings - Fork 6.4k
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
select: align poll emulation to return all relevant events #5883
Conversation
0b0adb5
to
9d093fd
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know if this is right. For example you are always setting POLLRDNORM on POLLIN afterwards but afaics that flag was not necessarily set beforehand. My understanding of poll is it is only supposed to write bits that were passed in, with the exceptions noted below. I think I agree with @bagder maybe it's best to take a if it ain't broke don't fix it approach here.
from posix poll:
In each pollfd structure, poll() shall clear the revents member, except that where the application requested a report on a condition by setting one of the bits of events listed above, poll() shall set the corresponding bit in revents if the requested condition is true. In addition, poll() shall set the POLLHUP, POLLERR, and POLLNVAL flag in revents if the condition is true, even if the application did not set the corresponding bit in events.
I don't think this is something that I am changing with this PR. The current code also sets POLLIN if that itself was not set, but instead POLLRDNORM was set. So I am basically extending it to be also the case the other way around. Of course, I can extend this PR to make sure to check for both flags being requested before setting them. Please see how the code already handles both types of flags on the pre-poll code path which I just want to reflect in the post-poll code path as well: Lines 400 to 405 in 147eca8
I somewhat agree on this, but I think the current code is partially broken, because it is not following the spec you referenced either. I will update this PR to reflect the spec even better. |
The poll emulation via select already consumes POLLRDNORM, POLLWRNORM and POLLRDBAND as input events. Therefore it should also return them as output events if signaled. Also fix indentation in input event handling block. Assisted-by: Daniel Stenberg Assisted-by: Jay Satiro Replaces curl#5852 Closes curl#5883
9d093fd
to
b517f72
Compare
I updated the PR to be in line with the POSIX specification. This should also make sure there are no side effects, because we won't return the "new" flags |
Fair enough, looks better now. |
The poll emulation via select already consumes POLLRDNORM,
POLLWRNORM and POLLRDBAND as input events. Therefore it
should also return them as output events if signaled.
Also fix indentation in input event handling block.
Assisted-by: Daniel Stenberg
Replaces #5852