Skip to content

SR-4026: dispatch_test_check_evfilt_read_for_fd for epoll #224

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

Merged
merged 1 commit into from
Feb 26, 2017

Conversation

dgrove-oss
Copy link
Contributor

Implement dispatch_test_check_evfilt_read_for_fd test method
for the event_epoll backend.

@MadCoder
Copy link
Contributor

that seems overly complicated, that thing only checks whether a given fd is readable whcih you can do with a very simple poll() call, you don't need epoll at all.

struct pollfd pfd = {
    .fd = fd,
    .events = EPOLLIN,
};
int rc;
do {
    rc = poll(&pfd, 1, 0);
} while (rc == -1 && errno == EINTR);
return rc == 1

should be it I think. we don't do that on Darwin because poll() actually is heavyweight and uses a short-lived kqueue.

@MadCoder
Copy link
Contributor

you may want to abort if poll returns -1 and the error isn't EINTR btw.

Implement dispatch_test_check_evfilt_read_for_fd test method
for the event_epoll backend.
@dgrove-oss dgrove-oss force-pushed the epoll_support_dispatch_test branch from a45430b to ee8143e Compare February 23, 2017 22:32
@dgrove-oss
Copy link
Contributor Author

Thanks; that is much more sensible. I got distracted by trying to use epoll, but you are right there is no reason to do it that way.

@MadCoder MadCoder merged commit 7ca0a63 into swiftlang:master Feb 26, 2017
@dgrove-oss dgrove-oss deleted the epoll_support_dispatch_test branch February 26, 2017 20:02
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

Successfully merging this pull request may close these issues.

2 participants