mirror of
https://github.com/mpv-player/mpv
synced 2025-01-18 13:14:36 +00:00
osdep: remove erroneous POLLERR emulation
first of all, POLLERR is supposed to be ignored in `.events` and only returned in `.revents`. secondly select()'s exceptfds does not have a 1:1 correspondence with POLLERR. thankfully, the only caller of this function (in terminal-unix) never set the POLLERR flag so the errorfds were unused anyways. so go ahead and remove it entirely instead of pretending we can emulate something that's not possible.
This commit is contained in:
parent
7ad7609541
commit
a61b784d90
@ -27,10 +27,9 @@
|
||||
int polldev(struct pollfd fds[], nfds_t nfds, int timeout) {
|
||||
#ifdef __APPLE__
|
||||
int maxfd = 0;
|
||||
fd_set readfds, writefds, errorfds;
|
||||
fd_set readfds, writefds;
|
||||
FD_ZERO(&readfds);
|
||||
FD_ZERO(&writefds);
|
||||
FD_ZERO(&errorfds);
|
||||
for (size_t i = 0; i < nfds; ++i) {
|
||||
struct pollfd *fd = &fds[i];
|
||||
if (fd->fd > maxfd) {
|
||||
@ -42,15 +41,12 @@ int polldev(struct pollfd fds[], nfds_t nfds, int timeout) {
|
||||
if ((fd->events & POLLOUT)) {
|
||||
FD_SET(fd->fd, &writefds);
|
||||
}
|
||||
if ((fd->events & POLLERR)) {
|
||||
FD_SET(fd->fd, &errorfds);
|
||||
}
|
||||
}
|
||||
struct timeval _timeout = {
|
||||
.tv_sec = timeout / 1000,
|
||||
.tv_usec = (timeout % 1000) * 1000
|
||||
};
|
||||
int n = select(maxfd + 1, &readfds, &writefds, &errorfds,
|
||||
int n = select(maxfd + 1, &readfds, &writefds, NULL,
|
||||
timeout != -1 ? &_timeout : NULL);
|
||||
if (n < 0) {
|
||||
return n;
|
||||
@ -64,9 +60,6 @@ int polldev(struct pollfd fds[], nfds_t nfds, int timeout) {
|
||||
if (FD_ISSET(fd->fd, &writefds)) {
|
||||
fd->revents |= POLLOUT;
|
||||
}
|
||||
if (FD_ISSET(fd->fd, &errorfds)) {
|
||||
fd->revents |= POLLERR;
|
||||
}
|
||||
}
|
||||
return n;
|
||||
#else
|
||||
|
@ -3,5 +3,5 @@
|
||||
#include <poll.h>
|
||||
|
||||
// Behaves like poll(3) but works for device files on macOS.
|
||||
// Only supports POLLIN, POLLOUT, and POLLERR.
|
||||
// Only supports POLLIN and POLLOUT.
|
||||
int polldev(struct pollfd fds[], nfds_t nfds, int timeout);
|
||||
|
Loading…
Reference in New Issue
Block a user