summaryrefslogtreecommitdiff
path: root/libavformat/tcp.c
diff options
context:
space:
mode:
authorLuca Barbato <lu_zero@gentoo.org>2011-04-04 18:17:12 +0200
committerLuca Barbato <lu_zero@gentoo.org>2011-04-07 02:53:55 +0200
commitebba2b3e2a551ce638d17332761431ba748f178f (patch)
tree5fded7a9455e3a83c513d594cf17337ad22c0096 /libavformat/tcp.c
parent1f6265e011f6e56562b2f58c182bc0261062b3c4 (diff)
proto: factor ff_network_wait_fd and use it on udp
Support the URL_FLAG_NONBLOCK semantic and uniform the protocol. The quick retry loop is already part of retry_transfer_wrapper. The polling routine is common to the network protocols: udp, tcp and, once merged, sctp.
Diffstat (limited to 'libavformat/tcp.c')
-rw-r--r--libavformat/tcp.c14
1 files changed, 2 insertions, 12 deletions
diff --git a/libavformat/tcp.c b/libavformat/tcp.c
index 37e6d6f10e..cf294dc4b9 100644
--- a/libavformat/tcp.c
+++ b/libavformat/tcp.c
@@ -131,23 +131,13 @@ static int tcp_open(URLContext *h, const char *uri, int flags)
return ret;
}
-static int tcp_wait_fd(int fd, int write)
-{
- int ev = write ? POLLOUT : POLLIN;
- struct pollfd p = { .fd = fd, .events = ev, .revents = 0 };
- int ret;
-
- ret = poll(&p, 1, 100);
- return ret < 0 ? ff_neterrno() : p.revents & ev ? 0 : AVERROR(EAGAIN);
-}
-
static int tcp_read(URLContext *h, uint8_t *buf, int size)
{
TCPContext *s = h->priv_data;
int ret;
if (!(h->flags & URL_FLAG_NONBLOCK)) {
- ret = tcp_wait_fd(s->fd, 0);
+ ret = ff_network_wait_fd(s->fd, 0);
if (ret < 0)
return ret;
}
@@ -161,7 +151,7 @@ static int tcp_write(URLContext *h, const uint8_t *buf, int size)
int ret;
if (!(h->flags & URL_FLAG_NONBLOCK)) {
- ret = tcp_wait_fd(s->fd, 1);
+ ret = ff_network_wait_fd(s->fd, 1);
if (ret < 0)
return ret;
}