Re: [PATCH v4 08/12] unix-socket: add backlog size option to unix_stream_listen()
- From
Jeff King <peff@peff.net>
- Date
- Feb 26, 2021, 07:30 UTC
- Message-ID
- <YDijhRaib5It/apG@coredump.intra.peff.net>
- In-Reply-To
- <985b2e02b2df7725d70f1365f7cd2e525c9f3ade.1613598529.git.gitgitgadget@gmail.com>
On Wed, Feb 17, 2021 at 09:48:44PM +0000, Jeff Hostetler via GitGitGadget wrote:
Show 10 quoted lines
> @@ -106,7 +108,10 @@ int unix_stream_listen(const char *path) > if (bind(fd, (struct sockaddr *)&sa, sizeof(sa)) < 0) > goto fail; > > - if (listen(fd, 5) < 0) > + backlog = opts->listen_backlog_size; > + if (backlog <= 0) > + backlog = DEFAULT_UNIX_STREAM_LISTEN_BACKLOG; > + if (listen(fd, backlog) < 0) > goto fail;
OK, so we still have the fallback-on-zero here, which is good...
Show 10 quoted lines
> +struct unix_stream_listen_opts {
> + int listen_backlog_size;
> +};
> +
> +#define DEFAULT_UNIX_STREAM_LISTEN_BACKLOG (5)
> +
> +#define UNIX_STREAM_LISTEN_OPTS_INIT \
> +{ \
> + .listen_backlog_size = DEFAULT_UNIX_STREAM_LISTEN_BACKLOG, \
> +}...but I thought the plan was to drop this initialization in favor of a zero-initialization. What you have certainly wouldn't do the wrong thing, but it just seems weirdly redundant. Unless some caller really wants to know what the default will be?
-Peff