]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: proxies: Add a per-thread group field to struct proxy.
authorOlivier Houchard <ohouchard@haproxy.com>
Wed, 15 Jan 2025 15:10:43 +0000 (16:10 +0100)
committerOlivier Houchard <cognet@ci0.org>
Tue, 28 Jan 2025 11:49:41 +0000 (12:49 +0100)
Add a per-thread group field to struct proxy, that will contain a struct
queue, as well as a new field, "queueslength".
This is currently unused, so should change nothing.
Please note that proxy_init_per_thr() must now be called for each proxy
once the thread groups number is known.

include/haproxy/proxy-t.h
include/haproxy/proxy.h
src/cfgparse.c
src/flt_spoe.c
src/proxy.c

index 4517e1d4e3c436689358d56a3c270aa045ecb4ef..d6f9cef4d9a26dc54bfb390f637b9f6d392126ef 100644 (file)
@@ -271,6 +271,11 @@ struct error_snapshot {
        char buf[VAR_ARRAY];                    /* copy of the beginning of the message for bufsize bytes */
 };
 
+/* Each proxy will have one occurence of this structure per thread group */
+struct proxy_per_tgroup {
+       struct queue queue;
+} THREAD_ALIGNED(64);
+
 struct proxy {
        enum obj_type obj_type;                 /* object type == OBJ_TYPE_PROXY */
        char flags;                             /* bit field PR_FL_* */
@@ -358,6 +363,8 @@ struct proxy {
 
        char *id, *desc;                        /* proxy id (name) and description */
        struct queue queue;                     /* queued requests (pendconns) */
+       struct proxy_per_tgroup *per_tgrp;      /* array of per-tgroup stuff such as queues */
+       unsigned int queueslength;              /* Sum of the length of each queue */
        int totpend;                            /* total number of pending connections on this instance (for stats) */
        unsigned int feconn, beconn;            /* # of active frontend and backends streams */
        unsigned int fe_sps_lim;                /* limit on new sessions per second on the frontend */
index 066ae6d8f03949c5f029c634484955e26ef515c9..3de1aa9eef59a8c68166134483a41dcb5e22324e 100644 (file)
@@ -87,6 +87,7 @@ struct proxy *cli_find_frontend(struct appctx *appctx, const char *arg);
 int resolve_stick_rule(struct proxy *curproxy, struct sticking_rule *mrule);
 void free_stick_rules(struct list *rules);
 void free_server_rules(struct list *srules);
+int proxy_init_per_thr(struct proxy *px);
 
 /*
  * This function returns a string containing the type of the proxy in a format
index de5405a9a427a3e17e4e50553aa0011f39f7e077..e57202a4f26707d746b55ffced1091a646d16911 100644 (file)
@@ -4307,6 +4307,7 @@ init_proxies_list_stage2:
                struct listener *listener;
                unsigned int next_id;
 
+               proxy_init_per_thr(curproxy);
                /* Configure SSL for each bind line.
                 * Note: if configuration fails at some point, the ->ctx member
                 * remains NULL so that listeners can later detach.
index 60c820c79b2e50a450f54b10d0f62b9fb3e47230..8f81e5494b0b846b70d7072a891b3eda848cd238 100644 (file)
@@ -1210,6 +1210,8 @@ static int spoe_init(struct proxy *px, struct flt_conf *fconf)
        conf->agent->fe.timeout.client = TICK_ETERNITY;
        conf->agent->fe.fe_req_ana = AN_REQ_SWITCHING_RULES;
 
+       proxy_init_per_thr(&conf->agent->fe);
+
        conf->agent->engine_id = generate_pseudo_uuid();
        if (conf->agent->engine_id == NULL)
                return -1;
index a794771f8380b6b4df8be05d648977ee6517d964..a1a4ee7343e67b45b86014b35bc293fb20fc3724 100644 (file)
@@ -407,6 +407,7 @@ void free_proxy(struct proxy *p)
 
        stktable_deinit(p->table);
        ha_free(&p->table);
+       ha_free(&p->per_tgrp);
 
        HA_RWLOCK_DESTROY(&p->lbprm.lock);
        HA_RWLOCK_DESTROY(&p->lock);
@@ -1463,6 +1464,18 @@ void init_new_proxy(struct proxy *p)
        proxy_preset_defaults(p);
 }
 
+/* Initialize per-thread proxy fields */
+int proxy_init_per_thr(struct proxy *px)
+{
+       int i;
+
+       px->per_tgrp = calloc(global.nbtgroups, sizeof(*px->per_tgrp));
+       for (i = 0; i < global.nbtgroups; i++)
+               queue_init(&px->per_tgrp[i].queue, px, NULL);
+
+       return 0;
+}
+
 /* Preset default settings onto proxy <defproxy>. */
 void proxy_preset_defaults(struct proxy *defproxy)
 {