From patchwork Mon Jan 10 16:51:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 33185 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:cd86:0:0:0:0:0 with SMTP id d128csp2897943iog; Mon, 10 Jan 2022 08:53:14 -0800 (PST) X-Google-Smtp-Source: ABdhPJyuD72AKswSldAUrpCKAmyIDWCYJJw2Nz02fwHjje1nFiOBTi02FLpwygvpOL8N7TYd3obL X-Received: by 2002:a17:906:6a0c:: with SMTP id qw12mr502387ejc.620.1641833594108; Mon, 10 Jan 2022 08:53:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1641833594; cv=none; d=google.com; s=arc-20160816; b=OJeVltJkQujU5WX7N8mEE3Mq8N6X4KNQXNt2EQkcXNh5GTrP3IKrVVxYESIgzHBXJA dpSMU3wVO7CdVWBHfekI2/V1fKI4I8H0EmkvLSKohRiAIELgg16ghqDdWKYeWwRO9YCA gPT8L2SdBhdXKZNCbY3BGrNtD4uV6dUKW0N5k9/IrU2iliCzsqm7gG+3t8tpmg9d04Sh eavxDM9/W4l9M2hXqbAKEg4avV3A+Dc/sWQoqgBBU7dHYQADA5nDcDDFlloRjyjIjoh3 8kdayCVcnABY4U8U9a9ngUhMuWa9+ZGoaZ0j05GcjCPpUAGwqeO2TyfJXH8nPdFtqV64 Uviw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:delivered-to; bh=NyOAkmx8+D8kKKfVj67HkzwZl3FuuwVFP3mD7bRwJY0=; b=hfohnzlBCrGhEVQdE9EspIRl8L97xjcH/UKylU7O1a/tvPkG7XI2f8Tki9ZTfU6tIY v7FXIf4wWVHj/2nlRNgVBvdRoG3jOmpCg+kQ+1aIDW0Z43EHYk3vbsaDUzMBwfkhW+iL hUj8AQ1PRccmrPLFW2p1MZdmyNJcCq1uxLhMK0iVC0eImuCh7+G0FxwrxzSiJrj2C5dI c06t7bMG7rSYGPLSRppzpqmsy7C3m5bKfcp97Prhy8DEp6a94Nb3pSv1Q6H54A/lus+l VxoXe6uVsp3HbigKz3hA0lJ6ntVeFCYgDoN0ehDBlH7bXmSNlf/eMwIw0JE7XvKALNBV nn5w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id y9si3612419edv.191.2022.01.10.08.53.13; Mon, 10 Jan 2022 08:53:14 -0800 (PST) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 977B668AB9D; Mon, 10 Jan 2022 18:52:42 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail0.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 4623068ABCA for ; Mon, 10 Jan 2022 18:52:34 +0200 (EET) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id DB0EF24017E for ; Mon, 10 Jan 2022 17:52:33 +0100 (CET) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id v_waiy2sJtzh for ; Mon, 10 Jan 2022 17:52:32 +0100 (CET) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail0.khirnov.net (Postfix) with ESMTPS id 820B82404FE for ; Mon, 10 Jan 2022 17:52:31 +0100 (CET) Received: by libav.khirnov.net (Postfix, from userid 1000) id 553BB3A073E; Mon, 10 Jan 2022 17:52:31 +0100 (CET) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Mon, 10 Jan 2022 17:51:43 +0100 Message-Id: <20220110165143.2292-3-anton@khirnov.net> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20220110165143.2292-1-anton@khirnov.net> References: <20220110165143.2292-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 3/4] lavf/network: log ff_socket() errors to proper contexts rather than NULL X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: W/qkHmnMEeCP --- 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)