Subject: re-listen(2) (was: <[email-masked]>)

From: Alejandro Colomar <[email-masked]>
Date: Sun, 24 Mar 2024 21:15:18 +0100

Hi Alexis,

I've fixed the subject, and CC.  You didn't send the mail to linux-man@.

I've also CCd netdev@, since they probably know better.

On Sun, Mar 24, 2024 at 10:16:02AM -0700, Alexis Wilke wrote:
> Hi Alejandro,
> 
> I was looking at changing the "backlog" of a listen(2) call and could not
> find any documentation on how to do so.
> 
> Clearly, it is possible under Linux simply by calling listen(2) again.
> However, the documentation does not mention the possibility.

Hmm, I see that POSIX doesn't specify either.

I didn't find it documented in linux.git/Documentation/ either (but I
only had a quick look; maybe it's there).

> We see on this stackoverflow post that it is how Nginx does it (see answer).

Nginx is known to abuse implementation details, and one shouldn't
necessarily trust what it does to be public API.

However, yeah, probably the kernel doesn't want to break Nginx, so maybe
we need to document it.  I'm not sure if this is a violation of POSIX,
though.  Maybe someone from netdev@ can confirm?

> https://stackoverflow.com/questions/64050281/can-backlog-value-that-is-passed-to-listen-call-be-modified-later-on-without-c
> 
> I would propose to either add a new paragraph or add one sentence to the
> existing "backlog" paragraph to mention the ability.
> 
> Here is the existing paragraph:
> 
>        The backlog argument defines the maximum length to which the
>        queue of pending connections for sockfd may grow. If a connection
>        request  arrives  when the queue is full, the client may receive an
> error
>        with an indication of ECONNREFUSED or, if the underlying
>        protocol supports retransmission, the request may be ignored so
>        that a later reattempt at connection succeeds.
> 
> What I propose is to add the following sentence to that paragraph:
> 
>        It is possible to call listen() again to change the the size of the
>        backlog queue.

Let's see what netdev@ says.

Have a lovely night!
Alex

> Thank you.
> Alexis

-- 
<https://www.alejandro-colomar.es/>
Looking for a remote C programming job at the moment.