summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNRK <nrk@disroot.org>2023-06-27 12:25:17 +0600
committersfan5 <sfan5@live.de>2023-06-29 13:17:56 +0200
commita61b784d90148bcd0e8e9c366dcc563c81c74026 (patch)
tree1ae29ffb53afd413f161f89470e2c5dc3af08cea
parent7ad76095417d1022aa4ba3c9a806ebb82004cbc4 (diff)
downloadmpv-a61b784d90148bcd0e8e9c366dcc563c81c74026.tar.bz2
mpv-a61b784d90148bcd0e8e9c366dcc563c81c74026.tar.xz
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.
-rw-r--r--osdep/polldev.c11
-rw-r--r--osdep/polldev.h2
2 files changed, 3 insertions, 10 deletions
diff --git a/osdep/polldev.c b/osdep/polldev.c
index ba2df2a2e3..dc86d5d022 100644
--- a/osdep/polldev.c
+++ b/osdep/polldev.c
@@ -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
diff --git a/osdep/polldev.h b/osdep/polldev.h
index 50b6db29bc..8593c1e77c 100644
--- a/osdep/polldev.h
+++ b/osdep/polldev.h
@@ -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);