]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: listener: move the nice field to the bind_conf
authorWilly Tarreau <w@1wt.eu>
Thu, 12 Jan 2023 18:32:45 +0000 (19:32 +0100)
committerWilly Tarreau <w@1wt.eu>
Fri, 3 Feb 2023 17:00:20 +0000 (18:00 +0100)
This is another bind line setting which can move to the bind_conf.
Note that it leaves a 2-byte hole in the listener struct.

include/haproxy/listener-t.h
src/cli.c
src/listener.c
src/session.c
src/stream.c

index 6edb52e51b644ab21cfbe85b44b7cb1fc1a9a7d6..33d7541bee707dcc276218bb185d0b3a1b7b6889 100644 (file)
@@ -206,6 +206,8 @@ struct bind_conf {
        int (*accept)(struct connection *conn); /* upper layer's accept() */
        int level;                 /* stats access level (ACCESS_LVL_*) */
        int severity_output;       /* default severity output format in cli feedback messages */
+       short int nice;            /* nice value to assign to the instantiated tasks */
+       /* 2-byte hole here */
        struct list listeners;     /* list of listeners using this bind config */
        uint32_t ns_cip_magic;     /* Excepted NetScaler Client IP magic number */
        struct list by_fe;         /* next binding for the same frontend, or NULL */
@@ -237,7 +239,7 @@ struct li_per_thread {
 struct listener {
        enum obj_type obj_type;         /* object type = OBJ_TYPE_LISTENER */
        enum li_state state;            /* state: NEW, INIT, ASSIGNED, LISTEN, READY, FULL */
-       short int nice;                 /* nice value to assign to the instantiated tasks */
+       /* 2-byte hole here */
        int luid;                       /* listener universally unique ID, used for SNMP */
        int options;                    /* socket options : LI_O_* */
        int flags;                      /* LI_F_* flags */
index 4b78fdac1b1bd93f10b7704ec6ee9a9605b66a24..b133b5febf2b62d1102da632c8983eb594107399 100644 (file)
--- a/src/cli.c
+++ b/src/cli.c
@@ -552,10 +552,10 @@ static int cli_parse_global(char **args, int section_type, struct proxy *curpx,
                }
 
                bind_conf->accept = session_accept_fd;
+               bind_conf->nice = -64;  /* we want to boost priority for local stats */
 
                list_for_each_entry(l, &bind_conf->listeners, by_bind) {
                        l->options |= LI_O_UNLIMITED; /* don't make the peers subject to global limits */
-                       l->nice = -64;  /* we want to boost priority for local stats */
                        global.maxsock++; /* for the listening socket */
                }
        }
@@ -3045,12 +3045,12 @@ struct bind_conf *mworker_cli_proxy_new_listener(char *line)
 
 
        bind_conf->accept = session_accept_fd;
+       bind_conf->nice = -64;  /* we want to boost priority for local stats */
 
        list_for_each_entry(l, &bind_conf->listeners, by_bind) {
                /* don't make the peers subject to global limits and don't close it in the master */
                l->options  |= LI_O_UNLIMITED;
                l->rx.flags |= RX_F_MWORKER; /* we are keeping this FD in the master */
-               l->nice = -64;  /* we want to boost priority for local stats */
                global.maxsock++; /* for the listening socket */
        }
        global.maxsock += mworker_proxy->maxconn;
@@ -3112,13 +3112,13 @@ int mworker_cli_sockpair_new(struct mworker_proc *mworker_proc, int proc)
        ha_free(&path);
 
        bind_conf->accept = session_accept_fd;
+       bind_conf->nice = -64;  /* we want to boost priority for local stats */
 
        list_for_each_entry(l, &bind_conf->listeners, by_bind) {
                l->options |= (LI_O_UNLIMITED | LI_O_NOSTOP);
                HA_ATOMIC_INC(&unstoppable_jobs);
                /* it's a sockpair but we don't want to keep the fd in the master */
                l->rx.flags &= ~RX_F_INHERITED;
-               l->nice = -64;  /* we want to boost priority for local stats */
                global.maxsock++; /* for the listening socket */
        }
 
index 86cf85cbacac1ae6d363a1c24f38489b8fc5745b..1635576d03b62cec486268c4399cf7ad013c3400 100644 (file)
@@ -1742,7 +1742,6 @@ static int bind_parse_name(char **args, int cur_arg, struct proxy *px, struct bi
 /* parse the "nice" bind keyword */
 static int bind_parse_nice(char **args, int cur_arg, struct proxy *px, struct bind_conf *conf, char **err)
 {
-       struct listener *l;
        int val;
 
        if (!*args[cur_arg + 1]) {
@@ -1756,9 +1755,7 @@ static int bind_parse_nice(char **args, int cur_arg, struct proxy *px, struct bi
                return ERR_ALERT | ERR_FATAL;
        }
 
-       list_for_each_entry(l, &conf->listeners, by_bind)
-               l->nice = val;
-
+       conf->nice = val;
        return 0;
 }
 
index 2788c59c9811ebdecf6063ccf033431bb4e8ad80..b15907d5e51bb6ec8980f39da461bf46a7dcf7e0 100644 (file)
@@ -266,7 +266,7 @@ int session_accept_fd(struct connection *cli_conn)
                        goto out_free_sess;
 
                sess->task->context = sess;
-               sess->task->nice    = l->nice;
+               sess->task->nice    = l->bind_conf->nice;
                sess->task->process = session_expire_embryonic;
                sess->task->expire  = tick_add_ifset(now_ms, p->timeout.client);
                task_queue(sess->task);
index 19e54b6662ab5be2e3cfcffa80e1c0f3cbb809df..b01f44d285d2bf4e3a1aaa1792bc1d9581424355 100644 (file)
@@ -434,7 +434,7 @@ struct stream *stream_new(struct session *sess, struct stconn *sc, struct buffer
        t->context = s;
        t->expire = TICK_ETERNITY;
        if (sess->listener)
-               t->nice = sess->listener->nice;
+               t->nice = sess->listener->bind_conf->nice;
 
        /* Note: initially, the stream's backend points to the frontend.
         * This changes later when switching rules are executed or