Commit e469c249 authored by Kenton Varda's avatar Kenton Varda

Work around poll() bug on MacOS: https://openradar.appspot.com/37537852

parent a90c65f4
......@@ -695,7 +695,16 @@ void UnixEventPort::FdObserver::fire(short events) {
short UnixEventPort::FdObserver::getEventMask() {
return (readFulfiller == nullptr ? 0 : (POLLIN | POLLRDHUP)) |
(writeFulfiller == nullptr ? 0 : POLLOUT) |
(urgentFulfiller == nullptr ? 0 : POLLPRI);
(urgentFulfiller == nullptr ? 0 : POLLPRI) |
// The POSIX standard says POLLHUP and POLLERR will be reported even if not requested.
// But on MacOS, if `events` is 0, then POLLHUP apparently will not be reported:
// https://openradar.appspot.com/37537852
// It seems that by settingc any non-zero value -- even one documented as ignored -- we
// cause POLLHUP to be reported. Both POLLHUP and POLLERR are documented as being ignored.
// So, we'll go ahead and set them. This has no effect on non-broken OSs, causes MacOS to
// do the right thing, and sort of looks as if we're explicitly requesting notification of
// these two conditions, which we do after all want to know about.
POLLHUP | POLLERR;
}
Promise<void> UnixEventPort::FdObserver::whenBecomesReadable() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment