-
Notifications
You must be signed in to change notification settings - Fork 11
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
Poll fixes #49
Poll fixes #49
Conversation
pollfd stores int fd so we need to: - make sure fd will fit into an int - explicitly cast it http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/poll.h.html
socketlist_get(S, *) requires a (size_t) for the second parameter. These casts are safe because we only store a value in .fd in growpollfd(), where it was passed as a (size_t).
growpollfd() requires a (size_t). This cast is safe because we've already checked that it's not < 0, and other code earlier in the function already does this type of cast anyway.
With these changes, the tests for spiped and kivaloo (without S3 tests) complete successfully. |
timeout = INT_MAX; | ||
else | ||
timeout = tv->tv_sec * 1000 + (tv->tv_usec + 999) / 1000; | ||
if (tv != NULL) { |
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.
Can you put this backwards, so that it becomes if ... else if ... else ? No point having unnecessary indentation.
Huh. I'm not surprised by the missing casts, but I must have been tired to miss the static declaration and the NULL timeout handling. Well, that's why we have tests, I guess... In case you didn't get an email: Please add Tim's comment fix (https://github.com/Tarsnap/libcperciva/pull/48/files/ff803364d8df10c718e56876fab1cdc02792d056#r97227373). |
The previous code relied on select(..., NULL) blocking: If the timeout parameter is a null pointer, then the call to pselect() or select() shall block indefinitely until at least one descriptor meets the specified criteria. http://pubs.opengroup.org/onlinepubs/9699919799/functions/select.html To reproduce this behaviour in the new code, If the value of timeout is -1, poll() shall block until a requested event occurs or until the call is interrupted. http://pubs.opengroup.org/onlinepubs/9699919799/functions/poll.html
Updated PR; still works with the spiped test. |
No description provided.