diff --git a/include/haproxy/proxy-t.h b/include/haproxy/proxy-t.h index 4517e1d4e..d6f9cef4d 100644 --- a/include/haproxy/proxy-t.h +++ b/include/haproxy/proxy-t.h @@ -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 */ diff --git a/include/haproxy/proxy.h b/include/haproxy/proxy.h index 066ae6d8f..3de1aa9ee 100644 --- a/include/haproxy/proxy.h +++ b/include/haproxy/proxy.h @@ -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 diff --git a/src/cfgparse.c b/src/cfgparse.c index de5405a9a..e57202a4f 100644 --- a/src/cfgparse.c +++ b/src/cfgparse.c @@ -4307,6 +4307,7 @@ int check_config_validity() 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. diff --git a/src/flt_spoe.c b/src/flt_spoe.c index 60c820c79..8f81e5494 100644 --- a/src/flt_spoe.c +++ b/src/flt_spoe.c @@ -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; diff --git a/src/proxy.c b/src/proxy.c index a794771f8..a1a4ee734 100644 --- a/src/proxy.c +++ b/src/proxy.c @@ -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 . */ void proxy_preset_defaults(struct proxy *defproxy) {