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

Poll fixes #49

Merged
merged 7 commits into from
Jan 22, 2017
Merged

Poll fixes #49

merged 7 commits into from
Jan 22, 2017

Conversation

gperciva
Copy link
Member

No description provided.

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.
@gperciva
Copy link
Member Author

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) {
Copy link
Member

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.

@cperciva
Copy link
Member

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).

gperciva and others added 2 commits January 22, 2017 13:53
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
@gperciva
Copy link
Member Author

Updated PR; still works with the spiped test.

@cperciva cperciva merged commit da2063b into master Jan 22, 2017
@gperciva gperciva deleted the poll-fixes branch January 22, 2017 23:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants