diff --git a/rtc_base/physical_socket_server.cc b/rtc_base/physical_socket_server.cc index cd4f854aa8..787e942f60 100644 --- a/rtc_base/physical_socket_server.cc +++ b/rtc_base/physical_socket_server.cc @@ -98,15 +98,15 @@ int64_t GetSocketRecvTimestamp(int socket) { typedef char* SockOptArg; #endif -#if defined(WEBRTC_USE_EPOLL) +#if defined(WEBRTC_LINUX) // POLLRDHUP / EPOLLRDHUP are only defined starting with Linux 2.6.17. #if !defined(POLLRDHUP) #define POLLRDHUP 0x2000 -#endif +#endif // !defined(POLLRDHUP) #if !defined(EPOLLRDHUP) #define EPOLLRDHUP 0x2000 -#endif -#endif +#endif // !defined(EPOLLRDHUP) +#endif // defined(WEBRTC_LINUX) namespace { @@ -1489,7 +1489,15 @@ static void ProcessEvents(Dispatcher* dispatcher, static void ProcessPollEvents(Dispatcher* dispatcher, const pollfd& pfd) { bool readable = (pfd.revents & (POLLIN | POLLPRI)); bool writable = (pfd.revents & POLLOUT); - bool error = (pfd.revents & (POLLRDHUP | POLLERR | POLLHUP)); + + // Linux and Fuchsia define POLLRDHUP, which is set when the peer has + // disconnected. On other platforms, we only check for POLLHUP. +#if defined(WEBRTC_LINUX) || defined(WEBRTC_FUCHSIA) + constexpr short kEvents = POLLRDHUP | POLLERR | POLLHUP; +#else + constexpr short kEvents = POLLERR | POLLHUP; +#endif + bool error = (pfd.revents & kEvents); ProcessEvents(dispatcher, readable, writable, error, error); } diff --git a/rtc_base/physical_socket_server.h b/rtc_base/physical_socket_server.h index ec30281e90..b8cf0420af 100644 --- a/rtc_base/physical_socket_server.h +++ b/rtc_base/physical_socket_server.h @@ -23,7 +23,7 @@ #include #define WEBRTC_USE_EPOLL 1 -#elif defined(WEBRTC_FUCHSIA) +#elif defined(WEBRTC_FUCHSIA) || defined(WEBRTC_MAC) // Fuchsia implements select and poll but not epoll, and testing shows that poll // is faster than select. #include @@ -31,7 +31,7 @@ #define WEBRTC_USE_POLL 1 #else // On other POSIX systems, use select by default. -#endif // WEBRTC_LINUX, WEBRTC_FUCHSIA +#endif // WEBRTC_LINUX, WEBRTC_FUCHSIA, WEBRTC_MAC #endif // WEBRTC_POSIX #include @@ -125,9 +125,6 @@ class RTC_EXPORT PhysicalSocketServer : public SocketServer { const int epoll_fd_ = INVALID_SOCKET; #elif defined(WEBRTC_USE_POLL) - void AddPoll(Dispatcher* dispatcher, uint64_t key); - void RemovePoll(Dispatcher* dispatcher); - void UpdatePoll(Dispatcher* dispatcher, uint64_t key); bool WaitPoll(int cmsWait, bool process_io); #endif // WEBRTC_USE_EPOLL, WEBRTC_USE_POLL