Commit d2519e86 authored by Anton Khirnov's avatar Anton Khirnov

lavf/network: log ff_socket() errors to proper contexts rather than NULL

parent 93b4cc38
...@@ -180,7 +180,7 @@ static int ff_poll_interrupt(struct pollfd *p, nfds_t nfds, int timeout, ...@@ -180,7 +180,7 @@ static int ff_poll_interrupt(struct pollfd *p, nfds_t nfds, int timeout,
return ret; return ret;
} }
int ff_socket(int af, int type, int proto) int ff_socket(int af, int type, int proto, void *logctx)
{ {
int fd; int fd;
...@@ -193,14 +193,14 @@ int ff_socket(int af, int type, int proto) ...@@ -193,14 +193,14 @@ int ff_socket(int af, int type, int proto)
#if HAVE_FCNTL #if HAVE_FCNTL
if (fd != -1) { if (fd != -1) {
if (fcntl(fd, F_SETFD, FD_CLOEXEC) == -1) if (fcntl(fd, F_SETFD, FD_CLOEXEC) == -1)
av_log(NULL, AV_LOG_DEBUG, "Failed to set close on exec\n"); av_log(logctx, AV_LOG_DEBUG, "Failed to set close on exec\n");
} }
#endif #endif
} }
#ifdef SO_NOSIGPIPE #ifdef SO_NOSIGPIPE
if (fd != -1) { if (fd != -1) {
if (setsockopt(fd, SOL_SOCKET, SO_NOSIGPIPE, &(int){1}, sizeof(int))) { if (setsockopt(fd, SOL_SOCKET, SO_NOSIGPIPE, &(int){1}, sizeof(int))) {
av_log(NULL, AV_LOG_WARNING, "setsockopt(SO_NOSIGPIPE) failed\n"); av_log(logctx, AV_LOG_WARNING, "setsockopt(SO_NOSIGPIPE) failed\n");
} }
} }
#endif #endif
...@@ -363,7 +363,7 @@ static int start_connect_attempt(struct ConnectionAttempt *attempt, ...@@ -363,7 +363,7 @@ static int start_connect_attempt(struct ConnectionAttempt *attempt,
*ptr = ai->ai_next; *ptr = ai->ai_next;
attempt->fd = ff_socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol); attempt->fd = ff_socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol, h);
if (attempt->fd < 0) if (attempt->fd < 0)
return ff_neterrno(); return ff_neterrno();
attempt->deadline_us = av_gettime_relative() + timeout_ms * 1000; attempt->deadline_us = av_gettime_relative() + timeout_ms * 1000;
......
...@@ -305,7 +305,7 @@ int ff_listen_connect(int fd, const struct sockaddr *addr, ...@@ -305,7 +305,7 @@ int ff_listen_connect(int fd, const struct sockaddr *addr,
int ff_http_match_no_proxy(const char *no_proxy, const char *hostname); int ff_http_match_no_proxy(const char *no_proxy, const char *hostname);
int ff_socket(int domain, int type, int protocol); int ff_socket(int domain, int type, int protocol, void *logctx);
void ff_log_net_error(void *ctx, int level, const char* prefix); void ff_log_net_error(void *ctx, int level, const char* prefix);
......
...@@ -220,7 +220,7 @@ static int sctp_open(URLContext *h, const char *uri, int flags) ...@@ -220,7 +220,7 @@ static int sctp_open(URLContext *h, const char *uri, int flags)
cur_ai = ai; cur_ai = ai;
restart: restart:
fd = ff_socket(cur_ai->ai_family, SOCK_STREAM, IPPROTO_SCTP); fd = ff_socket(cur_ai->ai_family, SOCK_STREAM, IPPROTO_SCTP, h);
if (fd < 0) { if (fd < 0) {
ret = ff_neterrno(); ret = ff_neterrno();
goto fail; goto fail;
......
...@@ -175,7 +175,7 @@ static int tcp_open(URLContext *h, const char *uri, int flags) ...@@ -175,7 +175,7 @@ static int tcp_open(URLContext *h, const char *uri, int flags)
while (cur_ai && fd < 0) { while (cur_ai && fd < 0) {
fd = ff_socket(cur_ai->ai_family, fd = ff_socket(cur_ai->ai_family,
cur_ai->ai_socktype, cur_ai->ai_socktype,
cur_ai->ai_protocol); cur_ai->ai_protocol, h);
if (fd < 0) { if (fd < 0) {
ret = ff_neterrno(); ret = ff_neterrno();
cur_ai = cur_ai->ai_next; cur_ai = cur_ai->ai_next;
......
...@@ -351,9 +351,9 @@ static int udp_socket_create(URLContext *h, struct sockaddr_storage *addr, ...@@ -351,9 +351,9 @@ static int udp_socket_create(URLContext *h, struct sockaddr_storage *addr,
goto fail; goto fail;
for (res = res0; res; res=res->ai_next) { for (res = res0; res; res=res->ai_next) {
if (s->udplite_coverage) if (s->udplite_coverage)
udp_fd = ff_socket(res->ai_family, SOCK_DGRAM, IPPROTO_UDPLITE); udp_fd = ff_socket(res->ai_family, SOCK_DGRAM, IPPROTO_UDPLITE, h);
else else
udp_fd = ff_socket(res->ai_family, SOCK_DGRAM, 0); udp_fd = ff_socket(res->ai_family, SOCK_DGRAM, 0, h);
if (udp_fd != -1) break; if (udp_fd != -1) break;
ff_log_net_error(h, AV_LOG_ERROR, "socket"); ff_log_net_error(h, AV_LOG_ERROR, "socket");
} }
......
...@@ -69,7 +69,7 @@ static int unix_open(URLContext *h, const char *filename, int flags) ...@@ -69,7 +69,7 @@ static int unix_open(URLContext *h, const char *filename, int flags)
s->addr.sun_family = AF_UNIX; s->addr.sun_family = AF_UNIX;
av_strlcpy(s->addr.sun_path, filename, sizeof(s->addr.sun_path)); av_strlcpy(s->addr.sun_path, filename, sizeof(s->addr.sun_path));
if ((fd = ff_socket(AF_UNIX, s->type, 0)) < 0) if ((fd = ff_socket(AF_UNIX, s->type, 0, h)) < 0)
return ff_neterrno(); return ff_neterrno();
if (s->timeout < 0 && h->rw_timeout) if (s->timeout < 0 && h->rw_timeout)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment