public inbox for gwml@vger.gnuweeb.org
 help / color / mirror / Atom feed
From: Alviro Iskandar Setiawan <alviro.iskandar@gnuweeb.org>
To: Ahmad Gani <reyuki@gnuweeb.org>
Cc: Ammar Faizi <ammarfaizi2@gnuweeb.org>,
	"GNU/Weeb Mailing List" <gwml@vger.gnuweeb.org>
Subject: Re: [PATCH gwproxy v0] epoll: Improve log readability and efficiency
Date: Sun, 17 Aug 2025 11:24:38 +0700	[thread overview]
Message-ID: <CAOG64qOiHK8K18jEzV6vgoWt4KT1U7iLczNB-D_=dCdiJUcmoQ@mail.gmail.com> (raw)
In-Reply-To: <20250817031621.81090-1-reyuki@gnuweeb.org>

On Sun, 17 Aug 2025 10:16:19 +0700, Ahmad Gani wrote:
> --- a/src/gwproxy/ev/epoll.c
> +++ b/src/gwproxy/ev/epoll.c
> @@ -325,24 +325,22 @@ static int __handle_ev_accept(struct gwp_wrk *w)
>         static const int flags = SOCK_NONBLOCK | SOCK_CLOEXEC;
>         struct gwp_ctx *ctx = w->ctx;
>         struct gwp_conn_pair *gcp;
> -       struct sockaddr *addr;
> +       struct gwp_sockaddr addr;
>         socklen_t addr_len;
>         int fd, r;
>
> +       addr_len = sizeof(addr);
> +       fd = __sys_accept4(w->tcp_fd, &addr.sa, &addr_len, flags);
> +       if (fd < 0)
> +               return handle_accept_error(w, fd);
> +
>         gcp = gwp_alloc_conn_pair(w);
>         if (unlikely(!gcp)) {
>                 pr_err(&ctx->lh, "Failed to allocate connection pair on accept");
>                 return handle_accept_error(w, -ENOMEM);
>         }

NAK.

If gwp_alloc_conn_pair() fails, you're leaking a TCP fd from
accept4(). After your changes, no one holds the returned fd except
that local variable.

  reply	other threads:[~2025-08-17  4:24 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-17  3:16 [PATCH gwproxy v0] epoll: Improve log readability and efficiency Ahmad Gani
2025-08-17  4:24 ` Alviro Iskandar Setiawan [this message]
2025-08-17  4:34   ` Ahmad Gani
2025-08-17  4:37     ` Ammar Faizi
2025-08-17  4:49       ` Ahmad Gani
2025-08-17  4:56         ` Ahmad Gani
2025-08-17  4:57         ` Ammar Faizi
2025-08-17  5:02           ` Ahmad Gani

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='CAOG64qOiHK8K18jEzV6vgoWt4KT1U7iLczNB-D_=dCdiJUcmoQ@mail.gmail.com' \
    --to=alviro.iskandar@gnuweeb.org \
    --cc=ammarfaizi2@gnuweeb.org \
    --cc=gwml@vger.gnuweeb.org \
    --cc=reyuki@gnuweeb.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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox