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

Properly handle EINTR when calling close() for a socket #21

Closed
saprykin opened this issue Jun 7, 2016 · 1 comment
Closed

Properly handle EINTR when calling close() for a socket #21

saprykin opened this issue Jun 7, 2016 · 1 comment
Assignees
Milestone

Comments

@saprykin
Copy link
Owner

saprykin commented Jun 7, 2016

Simply looping ans checking for the EINTR return code may lead to weird things in multithread environment. You can double-close a socket descriptor: the first time your own, and the next time allocated for another thread (with the same descriptor value). The problem is specifically unpleasant on some systems which may return with EINTR without actually closing a socket descriptor.

There is no general way to handle the close() call on all operating systems, so we need to do some checks.

Some related links:
http://alobbs.com/post/54503240599/close-and-eintr
https://bugs.chromium.org/p/chromium/issues/detail?id=269623
http://austingroupbugs.net/view.php?id=529
http://www.daemonology.net/blog/2011-12-17-POSIX-close-is-broken.html

@saprykin saprykin added this to the 0.0.1 milestone Jun 7, 2016
@saprykin saprykin self-assigned this Jun 7, 2016
@saprykin
Copy link
Owner Author

Done in bbc1241. For now only on HP-UX the ENINT code is handled in a repeat loop.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant