summaryrefslogtreecommitdiff
path: root/libavformat/udp.c
diff options
context:
space:
mode:
authorLuca Barbato <lu_zero@gentoo.org>2011-01-28 03:12:21 +0100
committerLuca Barbato <lu_zero@gentoo.org>2011-01-28 15:45:19 +0100
commita8475bbdb64e638bd8161df9647876fd23f8a29a (patch)
tree06d3c3a4999b0085f3fa0dbc8fa49cccb27350b7 /libavformat/udp.c
parent5ce5dbc5f3d0bce1f8d76fea1907c91469ebdd01 (diff)
downloadffmpeg-a8475bbdb64e638bd8161df9647876fd23f8a29a.tar.gz
os: replace select with poll
Select has limitations on the fd values it could accept and silently breaks when it is reached.
Diffstat (limited to 'libavformat/udp.c')
-rw-r--r--libavformat/udp.c15
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) {