@@ -72,7 +72,7 @@ int ff_network_wait_fd(int fd, int write)
struct pollfd p = { .fd = fd, .events = ev, .revents = 0 };
int ret;
ret = poll(&p, 1, POLLING_TIME);
- return ret < 0 ? ff_neterrno() : p.revents & (ev | POLLERR | POLLHUP) ? 0 : AVERROR(EAGAIN);
+ return ret < 0 ? ff_neterror() : p.revents & (ev | POLLERR | POLLHUP) ? 0 : AVERROR(EAGAIN);
}
int ff_network_wait_fd_timeout(int fd, int write, int64_t timeout, AVIOInterruptCB *int_cb)
@@ -121,7 +121,7 @@ void ff_network_close(void)
}
#if HAVE_WINSOCK2_H
-int ff_neterrno(void)
+int ff_neterror(void)
{
int err = WSAGetLastError();
switch (err) {
@@ -168,7 +168,7 @@ static int ff_poll_interrupt(struct pollfd *p, nfds_t nfds, int timeout,
ret = poll(p, nfds, POLLING_TIME);
if (ret != 0) {
if (ret < 0)
- ret = ff_neterrno();
+ ret = ff_neterror();
if (ret == AVERROR(EINTR))
continue;
break;
@@ -217,11 +217,11 @@ int ff_listen(int fd, const struct sockaddr *addr,
}
ret = bind(fd, addr, addrlen);
if (ret)
- return ff_neterrno();
+ return ff_neterror();
ret = listen(fd, 1);
if (ret)
- return ff_neterrno();
+ return ff_neterror();
return ret;
}
@@ -236,7 +236,7 @@ int ff_accept(int fd, int timeout, URLContext *h)
ret = accept(fd, NULL, NULL);
if (ret < 0)
- return ff_neterrno();
+ return ff_neterror();
if (ff_socket_nonblock(ret, 1) < 0)
av_log(h, AV_LOG_DEBUG, "ff_socket_nonblock failed\n");
@@ -267,7 +267,7 @@ int ff_listen_connect(int fd, const struct sockaddr *addr,
av_log(h, AV_LOG_DEBUG, "ff_socket_nonblock failed\n");
while ((ret = connect(fd, addr, addrlen))) {
- ret = ff_neterrno();
+ ret = ff_neterror();
switch (ret) {
case AVERROR(EINTR):
if (ff_check_interrupt(&h->interrupt_callback))
@@ -280,7 +280,7 @@ int ff_listen_connect(int fd, const struct sockaddr *addr,
return ret;
optlen = sizeof(ret);
if (getsockopt (fd, SOL_SOCKET, SO_ERROR, &ret, &optlen))
- ret = AVUNERROR(ff_neterrno());
+ ret = AVUNERROR(ff_neterror());
if (ret != 0) {
char errbuf[100];
ret = AVERROR(ret);
@@ -365,7 +365,7 @@ static int start_connect_attempt(struct ConnectionAttempt *attempt,
attempt->fd = ff_socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol, h);
if (attempt->fd < 0)
- return ff_neterrno();
+ return ff_neterror();
attempt->deadline_us = av_gettime_relative() + timeout_ms * 1000;
attempt->addr = ai;
@@ -381,7 +381,7 @@ static int start_connect_attempt(struct ConnectionAttempt *attempt,
}
while ((ret = connect(attempt->fd, ai->ai_addr, ai->ai_addrlen))) {
- ret = ff_neterrno();
+ ret = ff_neterror();
switch (ret) {
case AVERROR(EINTR):
if (ff_check_interrupt(&h->interrupt_callback)) {
@@ -478,7 +478,7 @@ int ff_connect_parallel(struct addrinfo *addrs, int timeout_ms_per_address,
// a successful connection or an error).
optlen = sizeof(last_err);
if (getsockopt(attempts[i].fd, SOL_SOCKET, SO_ERROR, &last_err, &optlen))
- last_err = ff_neterrno();
+ last_err = ff_neterror();
else if (last_err != 0)
last_err = AVERROR(last_err);
if (last_err == 0) {
@@ -587,6 +587,6 @@ int ff_http_match_no_proxy(const char *no_proxy, const char *hostname)
void ff_log_net_error(void *ctx, int level, const char* prefix)
{
char errbuf[100];
- av_strerror(ff_neterrno(), errbuf, sizeof(errbuf));
+ av_strerror(ff_neterror(), errbuf, sizeof(errbuf));
av_log(ctx, level, "%s: %s\n", prefix, errbuf);
}
@@ -62,7 +62,7 @@
* @return platform-specific AVERROR value
* @note Error is based on WSAGetLastError() (Windows) or `errno` (otherwise)
*/
-int ff_neterrno(void);
+int ff_neterror(void);
#else
#include <sys/types.h>
#include <sys/socket.h>
@@ -75,7 +75,7 @@ int ff_neterrno(void);
* @return platform-specific AVERROR value
* @note Error is based on WSAGetLastError() (Windows) or `errno` (otherwise)
*/
-#define ff_neterrno() AVERROR(errno)
+#define ff_neterror() AVERROR(errno)
#endif /* HAVE_WINSOCK2_H */
#if HAVE_ARPA_INET_H
@@ -410,8 +410,8 @@ static int rtp_read(URLContext *h, uint8_t *buf, int size)
len = recvfrom(p[i].fd, buf, size, 0,
(struct sockaddr *)addrs[i], addr_lens[i]);
if (len < 0) {
- if (ff_neterrno() == AVERROR(EAGAIN) ||
- ff_neterrno() == AVERROR(EINTR))
+ if (ff_neterror() == AVERROR(EAGAIN) ||
+ ff_neterror() == AVERROR(EINTR))
continue;
return AVERROR(EIO);
}
@@ -422,7 +422,7 @@ static int rtp_read(URLContext *h, uint8_t *buf, int size)
} else if (n == 0 && h->rw_timeout > 0 && --runs <= 0) {
return AVERROR(ETIMEDOUT);
} else if (n < 0) {
- if (ff_neterrno() == AVERROR(EINTR))
+ if (ff_neterror() == AVERROR(EINTR))
continue;
return AVERROR(EIO);
}
@@ -492,7 +492,7 @@ static int rtp_write(URLContext *h, const uint8_t *buf, int size)
ret = sendto(fd, buf, size, 0, (struct sockaddr *) source,
*source_len);
- return ret < 0 ? ff_neterrno() : ret;
+ return ret < 0 ? ff_neterror() : ret;
}
if (RTP_PT_IS_RTCP(buf[1])) {
@@ -222,7 +222,7 @@ static int sctp_open(URLContext *h, const char *uri, int flags)
restart:
fd = ff_socket(cur_ai->ai_family, SOCK_STREAM, IPPROTO_SCTP, h);
if (fd < 0) {
- ret = ff_neterrno();
+ ret = ff_neterror();
goto fail;
}
@@ -261,7 +261,7 @@ restart:
av_log(h, AV_LOG_ERROR,
"SCTP ERROR: Unable to initialize socket max streams %d\n",
s->max_streams);
- ret = ff_neterrno();
+ ret = ff_neterror();
goto fail1;
}
}
@@ -296,7 +296,7 @@ static int sctp_wait_fd(int fd, int write)
int ret;
ret = poll(&p, 1, 100);
- return ret < 0 ? ff_neterrno() : p.revents & ev ? 0 : AVERROR(EAGAIN);
+ return ret < 0 ? ff_neterror() : p.revents & ev ? 0 : AVERROR(EAGAIN);
}
static int sctp_read(URLContext *h, uint8_t *buf, int size)
@@ -319,7 +319,7 @@ static int sctp_read(URLContext *h, uint8_t *buf, int size)
} else
ret = recv(s->fd, buf, size, 0);
- return ret < 0 ? ff_neterrno() : ret;
+ return ret < 0 ? ff_neterror() : ret;
}
static int sctp_write(URLContext *h, const uint8_t *buf, int size)
@@ -345,7 +345,7 @@ static int sctp_write(URLContext *h, const uint8_t *buf, int size)
} else
ret = send(s->fd, buf, size, MSG_NOSIGNAL);
- return ret < 0 ? ff_neterrno() : ret;
+ return ret < 0 ? ff_neterror() : ret;
}
static int sctp_close(URLContext *h)
@@ -226,7 +226,7 @@ static int tcp_open(URLContext *h, const char *uri, int flags)
cur_ai->ai_socktype,
cur_ai->ai_protocol, h);
if (fd < 0) {
- ret = ff_neterrno();
+ ret = ff_neterror();
cur_ai = cur_ai->ai_next;
}
}
@@ -296,7 +296,7 @@ static int tcp_read(URLContext *h, uint8_t *buf, int size)
ret = recv(s->fd, buf, size, 0);
if (ret == 0)
return AVERROR_EOF;
- return ret < 0 ? ff_neterrno() : ret;
+ return ret < 0 ? ff_neterror() : ret;
}
static int tcp_write(URLContext *h, const uint8_t *buf, int size)
@@ -310,7 +310,7 @@ static int tcp_write(URLContext *h, const uint8_t *buf, int size)
return ret;
}
ret = send(s->fd, buf, size, MSG_NOSIGNAL);
- return ret < 0 ? ff_neterrno() : ret;
+ return ret < 0 ? ff_neterror() : ret;
}
static int tcp_shutdown(URLContext *h, int flags)
@@ -357,7 +357,7 @@ static int tcp_get_window_size(URLContext *h)
#endif
if (getsockopt(s->fd, SOL_SOCKET, SO_RCVBUF, &avail, &avail_len)) {
- return ff_neterrno();
+ return ff_neterror();
}
return avail;
}
@@ -190,7 +190,7 @@ static int udp_set_multicast_ttl(int sockfd, int mcastTTL,
ff_log_net_error(logctx, AV_LOG_DEBUG, "setsockopt(IPV4/IPV6 MULTICAST TTL)");
if (setsockopt(sockfd, protocol, cmd, &ttl, sizeof(ttl)) < 0) {
ff_log_net_error(logctx, AV_LOG_ERROR, "setsockopt(IPV4/IPV6 MULTICAST TTL)");
- return ff_neterrno();
+ return ff_neterror();
}
}
@@ -211,7 +211,7 @@ static int udp_join_multicast_group(int sockfd, struct sockaddr *addr,
mreq.imr_interface.s_addr = INADDR_ANY;
if (setsockopt(sockfd, IPPROTO_IP, IP_ADD_MEMBERSHIP, (const void *)&mreq, sizeof(mreq)) < 0) {
ff_log_net_error(logctx, AV_LOG_ERROR, "setsockopt(IP_ADD_MEMBERSHIP)");
- return ff_neterrno();
+ return ff_neterror();
}
}
#endif
@@ -224,7 +224,7 @@ static int udp_join_multicast_group(int sockfd, struct sockaddr *addr,
mreq6.ipv6mr_interface = 0;
if (setsockopt(sockfd, IPPROTO_IPV6, IPV6_ADD_MEMBERSHIP, &mreq6, sizeof(mreq6)) < 0) {
ff_log_net_error(logctx, AV_LOG_ERROR, "setsockopt(IPV6_ADD_MEMBERSHIP)");
- return ff_neterrno();
+ return ff_neterror();
}
}
#endif
@@ -294,7 +294,7 @@ static int udp_set_multicast_sources(URLContext *h,
ff_log_net_error(h, AV_LOG_ERROR, "setsockopt(MCAST_JOIN_SOURCE_GROUP)");
else
ff_log_net_error(h, AV_LOG_ERROR, "setsockopt(MCAST_BLOCK_SOURCE)");
- return ff_neterrno();
+ return ff_neterror();
}
}
return 0;
@@ -326,7 +326,7 @@ static int udp_set_multicast_sources(URLContext *h,
ff_log_net_error(h, AV_LOG_ERROR, "setsockopt(IP_ADD_SOURCE_MEMBERSHIP)");
else
ff_log_net_error(h, AV_LOG_ERROR, "setsockopt(IP_BLOCK_SOURCE)");
- return ff_neterrno();
+ return ff_neterror();
}
}
#else
@@ -508,8 +508,8 @@ static void *circular_buffer_task_rx( void *_URLContext)
pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &old_cancelstate);
pthread_mutex_lock(&s->mutex);
if (len < 0) {
- if (ff_neterrno() != AVERROR(EAGAIN) && ff_neterrno() != AVERROR(EINTR)) {
- s->circular_buffer_error = ff_neterrno();
+ if (ff_neterror() != AVERROR(EAGAIN) && ff_neterror() != AVERROR(EINTR)) {
+ s->circular_buffer_error = ff_neterror();
goto end;
}
continue;
@@ -621,7 +621,7 @@ static void *circular_buffer_task_tx( void *_URLContext)
len -= ret;
p += ret;
} else {
- ret = ff_neterrno();
+ ret = ff_neterror();
if (ret != AVERROR(EAGAIN) && ret != AVERROR(EINTR)) {
pthread_mutex_lock(&s->mutex);
s->circular_buffer_error = ret;
@@ -797,7 +797,7 @@ static int udp_open(URLContext *h, const char *uri, int flags)
if (s->reuse_socket > 0 || (s->is_multicast && s->reuse_socket < 0)) {
s->reuse_socket = 1;
if (setsockopt (udp_fd, SOL_SOCKET, SO_REUSEADDR, &(s->reuse_socket), sizeof(s->reuse_socket)) != 0) {
- ret = ff_neterrno();
+ ret = ff_neterror();
goto fail;
}
}
@@ -805,7 +805,7 @@ static int udp_open(URLContext *h, const char *uri, int flags)
if (s->is_broadcast) {
#ifdef SO_BROADCAST
if (setsockopt (udp_fd, SOL_SOCKET, SO_BROADCAST, &(s->is_broadcast), sizeof(s->is_broadcast)) != 0) {
- ret = ff_neterrno();
+ ret = ff_neterror();
goto fail;
}
#else
@@ -829,7 +829,7 @@ static int udp_open(URLContext *h, const char *uri, int flags)
if (dscp >= 0) {
dscp <<= 2;
if (setsockopt (udp_fd, IPPROTO_IP, IP_TOS, &dscp, sizeof(dscp)) != 0) {
- ret = ff_neterrno();
+ ret = ff_neterror();
goto fail;
}
}
@@ -846,7 +846,7 @@ static int udp_open(URLContext *h, const char *uri, int flags)
/* the bind is needed to give a port to the socket now */
if (bind_ret < 0 && bind(udp_fd,(struct sockaddr *)&my_addr, len) < 0) {
ff_log_net_error(h, AV_LOG_ERROR, "bind failed");
- ret = ff_neterrno();
+ ret = ff_neterror();
goto fail;
}
@@ -890,7 +890,7 @@ static int udp_open(URLContext *h, const char *uri, int flags)
tmp = s->buffer_size;
if (setsockopt(udp_fd, SOL_SOCKET, SO_SNDBUF, &tmp, sizeof(tmp)) < 0) {
ff_log_net_error(h, AV_LOG_ERROR, "setsockopt(SO_SNDBUF)");
- ret = ff_neterrno();
+ ret = ff_neterror();
goto fail;
}
} else {
@@ -914,7 +914,7 @@ static int udp_open(URLContext *h, const char *uri, int flags)
if (s->is_connected) {
if (connect(udp_fd, (struct sockaddr *) &s->dest_addr, s->dest_addr_len)) {
ff_log_net_error(h, AV_LOG_ERROR, "connect");
- ret = ff_neterrno();
+ ret = ff_neterror();
goto fail;
}
}
@@ -1045,7 +1045,7 @@ static int udp_read(URLContext *h, uint8_t *buf, int size)
}
ret = recvfrom(s->udp_fd, buf, size, 0, (struct sockaddr *)&addr, &addr_len);
if (ret < 0)
- return ff_neterrno();
+ return ff_neterror();
if (ff_ip_check_source_lists(&addr, &s->filters))
return AVERROR(EINTR);
return ret;
@@ -1098,7 +1098,7 @@ static int udp_write(URLContext *h, const uint8_t *buf, int size)
} else
ret = send(s->udp_fd, buf, size, 0);
- return ret < 0 ? ff_neterrno() : ret;
+ return ret < 0 ? ff_neterror() : ret;
}
static int udp_close(URLContext *h)
@@ -70,7 +70,7 @@ static int unix_open(URLContext *h, const char *filename, int flags)
av_strlcpy(s->addr.sun_path, filename, sizeof(s->addr.sun_path));
if ((fd = ff_socket(AF_UNIX, s->type, 0, h)) < 0)
- return ff_neterrno();
+ return ff_neterror();
if (s->timeout < 0 && h->rw_timeout)
s->timeout = h->rw_timeout / 1000;
@@ -113,7 +113,7 @@ static int unix_read(URLContext *h, uint8_t *buf, int size)
ret = recv(s->fd, buf, size, 0);
if (!ret && s->type == SOCK_STREAM)
return AVERROR_EOF;
- return ret < 0 ? ff_neterrno() : ret;
+ return ret < 0 ? ff_neterror() : ret;
}
static int unix_write(URLContext *h, const uint8_t *buf, int size)
@@ -127,7 +127,7 @@ static int unix_write(URLContext *h, const uint8_t *buf, int size)
return ret;
}
ret = send(s->fd, buf, size, MSG_NOSIGNAL);
- return ret < 0 ? ff_neterrno() : ret;
+ return ret < 0 ? ff_neterror() : ret;
}
static int unix_close(URLContext *h)
@@ -150,7 +150,7 @@ int ffurl_open_whitelist(URLContext **puc, const char *filename, int flags,
*
* @param s server context
* @param c client context, must be unallocated.
- * @return >= 0 on success, ff_neterrno() on failure.
+ * @return >= 0 on success, ff_neterror() on failure.
*/
int ffurl_accept(URLContext *s, URLContext **c);