[FFmpeg-cvslog] lavf/network: log ff_listen() errors to proper contexts rather than NULL

Anton Khirnov git at videolan.org
Fri Jan 21 10:40:27 EET 2022


ffmpeg | branch: master | Anton Khirnov <anton at khirnov.net> | Mon Jan 10 17:34:04 2022 +0100| [9e4693a1cbac13324bff9a57fa4dace405ee5ab9] | committer: Anton Khirnov

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

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=9e4693a1cbac13324bff9a57fa4dace405ee5ab9
---

 libavformat/network.c | 6 +++---
 libavformat/network.h | 3 ++-
 libavformat/tcp.c     | 2 +-
 3 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/libavformat/network.c b/libavformat/network.c
index c3d9f82551..246ffd406d 100644
--- a/libavformat/network.c
+++ b/libavformat/network.c
@@ -208,12 +208,12 @@ int ff_socket(int af, int type, int proto, void *logctx)
 }
 
 int ff_listen(int fd, const struct sockaddr *addr,
-              socklen_t addrlen)
+              socklen_t addrlen, void *logctx)
 {
     int ret;
     int reuse = 1;
     if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &reuse, sizeof(reuse))) {
-        av_log(NULL, AV_LOG_WARNING, "setsockopt(SO_REUSEADDR) failed\n");
+        av_log(logctx, AV_LOG_WARNING, "setsockopt(SO_REUSEADDR) failed\n");
     }
     ret = bind(fd, addr, addrlen);
     if (ret)
@@ -247,7 +247,7 @@ int ff_listen_bind(int fd, const struct sockaddr *addr,
                    socklen_t addrlen, int timeout, URLContext *h)
 {
     int ret;
-    if ((ret = ff_listen(fd, addr, addrlen)) < 0)
+    if ((ret = ff_listen(fd, addr, addrlen, h)) < 0)
         return ret;
     if ((ret = ff_accept(fd, timeout, h)) < 0)
         return ret;
diff --git a/libavformat/network.h b/libavformat/network.h
index d76166faf6..71c49a73fb 100644
--- a/libavformat/network.h
+++ b/libavformat/network.h
@@ -271,7 +271,8 @@ int ff_listen_bind(int fd, const struct sockaddr *addr,
  * @param addrlen Third argument of bind().
  * @return        0 on success or an AVERROR on failure.
  */
-int ff_listen(int fd, const struct sockaddr *addr, socklen_t addrlen);
+int ff_listen(int fd, const struct sockaddr *addr, socklen_t addrlen,
+              void *logctx);
 
 /**
  * Poll for a single connection on the passed file descriptor.
diff --git a/libavformat/tcp.c b/libavformat/tcp.c
index 84d40a1e11..a11ccbb913 100644
--- a/libavformat/tcp.c
+++ b/libavformat/tcp.c
@@ -188,7 +188,7 @@ static int tcp_open(URLContext *h, const char *uri, int flags)
 
     if (s->listen == 2) {
         // multi-client
-        if ((ret = ff_listen(fd, cur_ai->ai_addr, cur_ai->ai_addrlen)) < 0)
+        if ((ret = ff_listen(fd, cur_ai->ai_addr, cur_ai->ai_addrlen, h)) < 0)
             goto fail1;
     } else if (s->listen == 1) {
         // single client



More information about the ffmpeg-cvslog mailing list