From: Anton Khirnov <anton@khirnov.net>
To: ffmpeg-devel@ffmpeg.org
Subject: [FFmpeg-devel] [PATCH 3/4] lavf/network: log ff_socket() errors to proper contexts rather than NULL
Date: Mon, 10 Jan 2022 17:51:43 +0100
Message-ID: <20220110165143.2292-3-anton@khirnov.net> (raw)
In-Reply-To: <20220110165143.2292-1-anton@khirnov.net>
---
libavformat/network.c | 8 ++++----
libavformat/network.h | 2 +-
libavformat/sctp.c | 2 +-
libavformat/tcp.c | 2 +-
libavformat/udp.c | 4 ++--
libavformat/unix.c | 2 +-
6 files changed, 10 insertions(+), 10 deletions(-)
diff --git a/libavformat/network.c b/libavformat/network.c
index 0f5a575f77..c3d9f82551 100644
--- a/libavformat/network.c
+++ b/libavformat/network.c
@@ -180,7 +180,7 @@ static int ff_poll_interrupt(struct pollfd *p, nfds_t nfds, int timeout,
return ret;
}
-int ff_socket(int af, int type, int proto)
+int ff_socket(int af, int type, int proto, void *logctx)
{
int fd;
@@ -193,14 +193,14 @@ int ff_socket(int af, int type, int proto)
#if HAVE_FCNTL
if (fd != -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
}
#ifdef SO_NOSIGPIPE
if (fd != -1) {
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
@@ -363,7 +363,7 @@ static int start_connect_attempt(struct ConnectionAttempt *attempt,
*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)
return ff_neterrno();
attempt->deadline_us = av_gettime_relative() + timeout_ms * 1000;
diff --git a/libavformat/network.h b/libavformat/network.h
index 71347e815b..d76166faf6 100644
--- a/libavformat/network.h
+++ b/libavformat/network.h
@@ -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_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);
diff --git a/libavformat/sctp.c b/libavformat/sctp.c
index 9a80e9b015..b8e23653d2 100644
--- a/libavformat/sctp.c
+++ b/libavformat/sctp.c
@@ -220,7 +220,7 @@ static int sctp_open(URLContext *h, const char *uri, int flags)
cur_ai = ai;
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) {
ret = ff_neterrno();
goto fail;
diff --git a/libavformat/tcp.c b/libavformat/tcp.c
index 1c19aed887..84d40a1e11 100644
--- a/libavformat/tcp.c
+++ b/libavformat/tcp.c
@@ -175,7 +175,7 @@ static int tcp_open(URLContext *h, const char *uri, int flags)
while (cur_ai && fd < 0) {
fd = ff_socket(cur_ai->ai_family,
cur_ai->ai_socktype,
- cur_ai->ai_protocol);
+ cur_ai->ai_protocol, h);
if (fd < 0) {
ret = ff_neterrno();
cur_ai = cur_ai->ai_next;
diff --git a/libavformat/udp.c b/libavformat/udp.c
index d1195ceca9..83c042d079 100644
--- a/libavformat/udp.c
+++ b/libavformat/udp.c
@@ -351,9 +351,9 @@ static int udp_socket_create(URLContext *h, struct sockaddr_storage *addr,
goto fail;
for (res = res0; res; res=res->ai_next) {
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
- 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;
ff_log_net_error(h, AV_LOG_ERROR, "socket");
}
diff --git a/libavformat/unix.c b/libavformat/unix.c
index 38016dbafe..e668744580 100644
--- a/libavformat/unix.c
+++ b/libavformat/unix.c
@@ -69,7 +69,7 @@ static int unix_open(URLContext *h, const char *filename, int flags)
s->addr.sun_family = AF_UNIX;
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();
if (s->timeout < 0 && h->rw_timeout)
--
2.33.0
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
next prev parent reply other threads:[~2022-01-10 16:53 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-10 16:51 [FFmpeg-devel] [PATCH 1/4] lavf/udp: do not return an uninitialized value from udp_open() Anton Khirnov
2022-01-10 16:51 ` [FFmpeg-devel] [PATCH 2/4] lavf/udp: log net errors to proper contexts rather than NULL Anton Khirnov
2022-01-10 16:51 ` Anton Khirnov [this message]
2022-01-10 16:51 ` [FFmpeg-devel] [PATCH 4/4] lavf/network: log ff_listen() " Anton Khirnov
2022-01-10 17:51 ` [FFmpeg-devel] [PATCH 1/4] lavf/udp: do not return an uninitialized value from udp_open() James Almer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220110165143.2292-3-anton@khirnov.net \
--to=anton@khirnov.net \
--cc=ffmpeg-devel@ffmpeg.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
This inbox may be cloned and mirrored by anyone:
git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
ffmpegdev@gitmailbox.com
public-inbox-index ffmpegdev
Example config snippet for mirrors.
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git