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

select() problems with time events #1

Closed
SilvanScherrer opened this issue Feb 26, 2020 · 2 comments
Closed

select() problems with time events #1

SilvanScherrer opened this issue Feb 26, 2020 · 2 comments

Comments

@SilvanScherrer
Copy link

libevent can add events on sockets or events for timeouts w/o any socket attached. Events with sockets work as select can handle that. But when timeout events are added they get added with a fd of -1. and as the select_init of libevent always creates a fd_set we end up calling select with an fd_set but 0 ndfs. This gives a EINTR, which is not right. It just should wait the time in timeout.

@dmik
Copy link

dmik commented Feb 26, 2020

Looks like LIBC select simply doesn't expect this situation. POSIX is silent about this particular case. However, Linux is pretty verbose:

Some code calls select() with all three sets empty, nfds zero, and a
non-NULL timeout as a fairly portable way to sleep with subsecond
precision.

Which means that a zero ndfs value and empty sets should trigger a wait cycle (if specified). And that's what all other platforms do. I will fix LIBC to do the same.

@dmik
Copy link

dmik commented Feb 26, 2020

Note that the above fix will always cause a wait cycle if nfds is 0, i.e. it's not strictly necessary for FD sets to be empty. But given that this is non-POSIX (non-standard) behavior anyway, I think it's OK for the sake of code simplicity. If we find any compatibility issue, we will reconsider this.

Please check and feel free to reopen if it doesn't fix libevent tests for you. The test build of LIBC is available in /test.

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

No branches or pull requests

2 participants