diff options
author | Luca Barbato <lu_zero@gentoo.org> | 2011-01-28 03:12:21 +0100 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2011-01-30 03:40:59 +0100 |
commit | d0eb91ad0451cdb6c062b2d4760bfa7f8bb4db6b (patch) | |
tree | aad8df0b1a480fbcdcae278fe393f287106d76d3 /libavformat/udp.c | |
parent | b5f83debf5384195c8700d024fb760ab8d7250aa (diff) | |
download | ffmpeg-d0eb91ad0451cdb6c062b2d4760bfa7f8bb4db6b.tar.gz |
os: replace select with poll
Select has limitations on the fd values it could accept and silently
breaks when it is reached.
(cherry picked from commit a8475bbdb64e638bd8161df9647876fd23f8a29a)
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) { |