[systemd-devel] [PATCH] core: support Distribute=n to distribute to n workers

Lennart Poettering lennart at poettering.net
Fri Dec 13 07:12:46 PST 2013


On Thu, 12.12.13 23:46, Shawn Landden (shawn at churchofgit.com) wrote:

> -Socket.ReusePort,                config_parse_bool,                  0,                             offsetof(Socket, reuse_port)
> +Socket.ReusePort,                config_parse_tristate,             -1,                             offsetof(Socket, reuse_port)
                                                                      ^^^^^

Why -1 there? That should be there... The parse call doesn't make use of
that, so it should be 0, really.


> +        if (s->reuse_port < 0) {
> +                if (s->distribute > 0)
> +                        s->reuse_port = true;
> +                else
> +                        s->reuse_port = false;
> +        }
> +


Nitpicking: I'd just write it like this:

if (s->reuse_port < 0) 
        s->reuse_port = s->distribute > 0;


> -                if (s->n_connections >= s->max_connections) {
> +                if (s->n_connections >= s->max_connections && !(s->distribute)) {

Still too many ()....

>  
> -        if (se->state == SERVICE_RUNNING)
> -                socket_set_state(s, SOCKET_RUNNING);
> +        if (se->state == SERVICE_RUNNING) {
> +                if (s->n_connections < s->distribute)
> +                        ;
> +                else
> +                        socket_set_state(s, SOCKET_RUNNING);
> +        }

Hmm, too simple, no? We wanted that logic, that we enter
SOCKET_RUNNING as long as at least one service is still starting up or
when we reached the limit. I only see the check for the latter here...

Still missing the bit where the socket is duplicated for propery
SO_REUSEPORT usgae...


Lennart

-- 
Lennart Poettering, Red Hat


More information about the systemd-devel mailing list