Re: [PATCH ucspi-vsock 7/7] Extract vsockserver-socketbinder and vsockserverd

Alyssa Ross
2021-03-20T20:55:53Z

[-- Attachment #1: Type: text/plain, Size: 1526 bytes --]

On Thu, Mar 18, 2021 at 08:39:31PM -0700, Cole Helbling wrote:
> > + if (listen(fd ,40) == -1)
>
> Minor formatting nit (comma, then space); but also, what is `40`
> representative of? Should this be `#define`d, or otherwise assigned to
> some descriptive name?

Looks like the next thing I should do after this is set up clang-tidy or
something. ;)

It's the backlog parameter, i.e. the minimum[1] number of connections
the kernel should allow to queue up before it starts rejecting them.

Would the following additional diff make you happy? :)
(I won't bother resending the whole patch with it applied; for the
purposes of reviewing just pretend this is part of the patch I sent.)

[1]: https://utcc.utoronto.ca/~cks/space/blog/unix/ListenBacklogMeaning

PS: cool thing I just discovered -- you can pipe this message to
git apply, and it'll find and apply the diff (without trying to make
a commit like git am would).

diff --git i/vsockserver-socketbinder.c w/vsockserver-socketbinder.c
index 598c01c..fdcdfa8 100644
--- i/vsockserver-socketbinder.c
+++ w/vsockserver-socketbinder.c
@@ -20,6 +20,8 @@
#include "num.h"
#include "vsock.h"

+static const int LISTEN_BACKLOG = 40;
+
noreturn static void ex_usage(void)
{
if (verbosity)
@@ -71,7 +73,7 @@ int main(int argc, char *argv[])
diee(EX_OSERR, "fcntl");
if (vsock_bind(fd, cid, port) == -1)
diee(EX_OSERR, "bind");
- if (listen(fd ,40) == -1)
+ if (listen(fd, LISTEN_BACKLOG) == -1)
diee(EX_OSERR, "listen");

// Place the socket at stdout.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]