X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=src%2Fnetwork%2Fpoll.c;h=cf9554a30ab687c453425985cf52f6a025b24820;hb=91ff0ff529a172440ff0d09d206267220d6a2d5b;hp=540bc1dac6dff11664c75bee5fef24ed4c44b1e4;hpb=6fa6b93bb399e82d95cc9cef012b3bf125ba4fce;p=vlc diff --git a/src/network/poll.c b/src/network/poll.c index 540bc1dac6..cf9554a30a 100644 --- a/src/network/poll.c +++ b/src/network/poll.c @@ -26,17 +26,31 @@ #endif #include - -#ifndef HAVE_POLL -#include #include #include -int poll (struct pollfd *fds, unsigned nfds, int timeout) + +#ifdef HAVE_POLL +struct pollfd; + +int vlc_poll (struct pollfd *fds, unsigned nfds, int timeout) +{ + (void)fds; (void)nfds; (void)timeout; + abort (); +} +#else /* !HAVE_POLL */ + +#include + +int vlc_poll (struct pollfd *fds, unsigned nfds, int timeout) { fd_set rdset, wrset, exset; struct timeval tv = { 0, 0 }; - int val = -1; + int val; + +resume: + val = -1; + vlc_testcancel (); FD_ZERO (&rdset); FD_ZERO (&wrset); @@ -75,6 +89,15 @@ int poll (struct pollfd *fds, unsigned nfds, int timeout) FD_SET (fd, &exset); } +#ifndef HAVE_ALERTABLE_SELECT +# warning FIXME! Fix cancellation and remove this crap. + if ((timeout < 0) || (timeout > 50)) + { + tv.tv_sec = 0; + tv.tv_usec = 50000; + } + else +#endif if (timeout >= 0) { div_t d = div (timeout, 1000); @@ -83,7 +106,18 @@ int poll (struct pollfd *fds, unsigned nfds, int timeout) } val = select (val + 1, &rdset, &wrset, &exset, - (timeout >= 0) ? &tv : NULL); + /*(timeout >= 0) ?*/ &tv /*: NULL*/); + +#ifndef HAVE_ALERTABLE_SELECT + if (val == 0) + { + if (timeout > 0) + timeout -= (timeout > 50) ? 50 : timeout; + if (timeout != 0) + goto resume; + } +#endif + if (val == -1) return -1;