From a8475bbdb64e638bd8161df9647876fd23f8a29a Mon Sep 17 00:00:00 2001 From: Luca Barbato Date: Fri, 28 Jan 2011 03:12:21 +0100 Subject: os: replace select with poll Select has limitations on the fd values it could accept and silently breaks when it is reached. --- libavformat/udp.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) (limited to 'libavformat/udp.c') 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 +#if HAVE_POLL_H +#include #endif #include @@ -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) { -- cgit v1.2.3