From: Willy Tarreau Date: Thu, 12 Jan 2023 18:32:45 +0000 (+0100) Subject: MINOR: listener: move the nice field to the bind_conf X-Git-Tag: v2.8-dev3~19 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=7dbd4187dc3fc370ef22e9aaf02f2b46cdd0acd5;p=thirdparty%2Fhaproxy.git MINOR: listener: move the nice field to the bind_conf 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. --- diff --git a/include/haproxy/listener-t.h b/include/haproxy/listener-t.h index 6edb52e51b..33d7541bee 100644 --- a/include/haproxy/listener-t.h +++ b/include/haproxy/listener-t.h @@ -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 */ diff --git a/src/cli.c b/src/cli.c index 4b78fdac1b..b133b5febf 100644 --- 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 */ } diff --git a/src/listener.c b/src/listener.c index 86cf85cbac..1635576d03 100644 --- a/src/listener.c +++ b/src/listener.c @@ -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; } diff --git a/src/session.c b/src/session.c index 2788c59c98..b15907d5e5 100644 --- a/src/session.c +++ b/src/session.c @@ -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); diff --git a/src/stream.c b/src/stream.c index 19e54b6662..b01f44d285 100644 --- a/src/stream.c +++ b/src/stream.c @@ -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