diff options
author | Alex Beregszaszi <alex@rtfs.hu> | 2007-04-27 00:35:54 +0000 |
---|---|---|
committer | Alex Beregszaszi <alex@rtfs.hu> | 2007-04-27 00:35:54 +0000 |
commit | 8da4034f529f3c5dcc3f95a7d81032cc9be543fb (patch) | |
tree | dc3e28a55483f023bb7c13d27630f58830a4af02 /libavformat | |
parent | 0bdacf29d40b11cfd5dd0d13577a4bdc90afdcea (diff) | |
download | ffmpeg-8da4034f529f3c5dcc3f95a7d81032cc9be543fb.tar.gz |
use ff_neterrno() and FF_NETERROR() for networking error handling
Originally committed as revision 8845 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavformat')
-rw-r--r-- | libavformat/network.h | 3 | ||||
-rw-r--r-- | libavformat/rtpproto.c | 9 | ||||
-rw-r--r-- | libavformat/tcp.c | 10 | ||||
-rw-r--r-- | libavformat/udp.c | 6 |
4 files changed, 19 insertions, 9 deletions
diff --git a/libavformat/network.h b/libavformat/network.h index 3aa8ba8367..7dcbfe244c 100644 --- a/libavformat/network.h +++ b/libavformat/network.h @@ -29,6 +29,9 @@ #endif #include <netdb.h> +#define ff_neterrno() errno +#define FF_NETERROR(err) err + #if !defined(HAVE_INET_ATON) /* in os_support.c */ int inet_aton (const char * str, struct in_addr * add); diff --git a/libavformat/rtpproto.c b/libavformat/rtpproto.c index 4d32e667da..369a8057d2 100644 --- a/libavformat/rtpproto.c +++ b/libavformat/rtpproto.c @@ -178,7 +178,8 @@ static int rtp_read(URLContext *h, uint8_t *buf, int size) len = recvfrom (s->rtp_fd, buf, size, 0, (struct sockaddr *)&from, &from_len); if (len < 0) { - if (errno == EAGAIN || errno == EINTR) + if (ff_neterrno() == FF_NETERROR(EAGAIN) || + ff_neterrno() == FF_NETERROR(EINTR)) continue; return AVERROR_IO; } @@ -201,7 +202,8 @@ static int rtp_read(URLContext *h, uint8_t *buf, int size) len = recvfrom (s->rtcp_fd, buf, size, 0, (struct sockaddr *)&from, &from_len); if (len < 0) { - if (errno == EAGAIN || errno == EINTR) + if (ff_neterrno() == FF_NETERROR(EAGAIN) || + ff_neterrno() == FF_NETERROR(EINTR)) continue; return AVERROR_IO; } @@ -213,7 +215,8 @@ static int rtp_read(URLContext *h, uint8_t *buf, int size) len = recvfrom (s->rtp_fd, buf, size, 0, (struct sockaddr *)&from, &from_len); if (len < 0) { - if (errno == EAGAIN || errno == EINTR) + if (ff_neterrno() == FF_NETERROR(EAGAIN) || + ff_neterrno() == FF_NETERROR(EINTR)) continue; return AVERROR_IO; } diff --git a/libavformat/tcp.c b/libavformat/tcp.c index 40aba66a2d..b2f6d37a76 100644 --- a/libavformat/tcp.c +++ b/libavformat/tcp.c @@ -68,9 +68,9 @@ static int tcp_open(URLContext *h, const char *uri, int flags) ret = connect(fd, (struct sockaddr *)&dest_addr, sizeof(dest_addr)); if (ret < 0) { - if (errno == EINTR) + if (ff_neterrno() == FF_NETERROR(EINTR)) goto redo; - if (errno != EINPROGRESS) + if (ff_neterrno() != FF_NETERROR(EINPROGRESS)) goto fail; /* wait until we are connected or until abort */ @@ -126,7 +126,8 @@ static int tcp_read(URLContext *h, uint8_t *buf, int size) if (ret > 0 && FD_ISSET(s->fd, &rfds)) { len = recv(s->fd, buf, size, 0); if (len < 0) { - if (errno != EINTR && errno != EAGAIN) + if (ff_neterrno() != FF_NETERROR(EINTR) && + ff_neterrno() != FF_NETERROR(EAGAIN)) return AVERROR(errno); } else return len; } else if (ret < 0) { @@ -155,7 +156,8 @@ static int tcp_write(URLContext *h, uint8_t *buf, int size) if (ret > 0 && FD_ISSET(s->fd, &wfds)) { len = send(s->fd, buf, size, 0); if (len < 0) { - if (errno != EINTR && errno != EAGAIN) + if (ff_neterrno() != FF_NETERROR(EINTR) && + ff_neterrno() != FF_NETERROR(EAGAIN)) return AVERROR(errno); continue; } diff --git a/libavformat/udp.c b/libavformat/udp.c index bbf8ca2ec6..e8721ce734 100644 --- a/libavformat/udp.c +++ b/libavformat/udp.c @@ -428,7 +428,8 @@ static int udp_read(URLContext *h, uint8_t *buf, int size) len = recvfrom (s->udp_fd, buf, size, 0, (struct sockaddr *)&from, &from_len); if (len < 0) { - if (errno != EAGAIN && errno != EINTR) + if (ff_neterrno() != FF_NETERROR(EAGAIN) && + ff_neterrno() != FF_NETERROR(EINTR)) return AVERROR_IO; } else { break; @@ -451,7 +452,8 @@ static int udp_write(URLContext *h, uint8_t *buf, int size) s->dest_addr_len); #endif if (ret < 0) { - if (errno != EINTR && errno != EAGAIN) + if (ff_neterrno() != FF_NETERROR(EINTR) && + ff_neterrno() != FF_NETERROR(EAGAIN)) return AVERROR_IO; } else { break; |