diff options
Diffstat (limited to 'libavformat/udp.c')
-rw-r--r-- | libavformat/udp.c | 15 |
1 files changed, 5 insertions, 10 deletions
diff --git a/libavformat/udp.c b/libavformat/udp.c index 8080c98045..aa17c979f3 100644 --- a/libavformat/udp.c +++ b/libavformat/udp.c @@ -31,8 +31,8 @@ #include "internal.h" #include "network.h" #include "os_support.h" -#if HAVE_SYS_SELECT_H -#include <sys/select.h> +#if HAVE_POLL_H +#include <poll.h> #endif #include <sys/time.h> @@ -432,25 +432,20 @@ static int udp_open(URLContext *h, const char *uri, int flags) static int udp_read(URLContext *h, uint8_t *buf, int size) { UDPContext *s = h->priv_data; + struct pollfd p = {s->udp_fd, POLLIN, 0}; int len; - fd_set rfds; int ret; - struct timeval tv; for(;;) { if (url_interrupt_cb()) return AVERROR(EINTR); - FD_ZERO(&rfds); - FD_SET(s->udp_fd, &rfds); - tv.tv_sec = 0; - tv.tv_usec = 100 * 1000; - ret = select(s->udp_fd + 1, &rfds, NULL, NULL, &tv); + ret = poll(&p, 1, 100); if (ret < 0) { if (ff_neterrno() == FF_NETERROR(EINTR)) continue; return AVERROR(EIO); } - if (!(ret > 0 && FD_ISSET(s->udp_fd, &rfds))) + if (!(ret == 1 && p.revents & POLLIN)) continue; len = recv(s->udp_fd, buf, size, 0); if (len < 0) { |