mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-08-07 15:47:01 +02:00
MINOR: proxies: Add a per-thread group field to struct proxy.
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.
This commit is contained in:
parent
7fa70da06d
commit
f879b9a18a
@ -271,6 +271,11 @@ struct error_snapshot {
|
|||||||
char buf[VAR_ARRAY]; /* copy of the beginning of the message for bufsize bytes */
|
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 {
|
struct proxy {
|
||||||
enum obj_type obj_type; /* object type == OBJ_TYPE_PROXY */
|
enum obj_type obj_type; /* object type == OBJ_TYPE_PROXY */
|
||||||
char flags; /* bit field PR_FL_* */
|
char flags; /* bit field PR_FL_* */
|
||||||
@ -358,6 +363,8 @@ struct proxy {
|
|||||||
|
|
||||||
char *id, *desc; /* proxy id (name) and description */
|
char *id, *desc; /* proxy id (name) and description */
|
||||||
struct queue queue; /* queued requests (pendconns) */
|
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) */
|
int totpend; /* total number of pending connections on this instance (for stats) */
|
||||||
unsigned int feconn, beconn; /* # of active frontend and backends streams */
|
unsigned int feconn, beconn; /* # of active frontend and backends streams */
|
||||||
unsigned int fe_sps_lim; /* limit on new sessions per second on the frontend */
|
unsigned int fe_sps_lim; /* limit on new sessions per second on the frontend */
|
||||||
|
@ -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);
|
int resolve_stick_rule(struct proxy *curproxy, struct sticking_rule *mrule);
|
||||||
void free_stick_rules(struct list *rules);
|
void free_stick_rules(struct list *rules);
|
||||||
void free_server_rules(struct list *srules);
|
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
|
* This function returns a string containing the type of the proxy in a format
|
||||||
|
@ -4307,6 +4307,7 @@ int check_config_validity()
|
|||||||
struct listener *listener;
|
struct listener *listener;
|
||||||
unsigned int next_id;
|
unsigned int next_id;
|
||||||
|
|
||||||
|
proxy_init_per_thr(curproxy);
|
||||||
/* Configure SSL for each bind line.
|
/* Configure SSL for each bind line.
|
||||||
* Note: if configuration fails at some point, the ->ctx member
|
* Note: if configuration fails at some point, the ->ctx member
|
||||||
* remains NULL so that listeners can later detach.
|
* remains NULL so that listeners can later detach.
|
||||||
|
@ -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.timeout.client = TICK_ETERNITY;
|
||||||
conf->agent->fe.fe_req_ana = AN_REQ_SWITCHING_RULES;
|
conf->agent->fe.fe_req_ana = AN_REQ_SWITCHING_RULES;
|
||||||
|
|
||||||
|
proxy_init_per_thr(&conf->agent->fe);
|
||||||
|
|
||||||
conf->agent->engine_id = generate_pseudo_uuid();
|
conf->agent->engine_id = generate_pseudo_uuid();
|
||||||
if (conf->agent->engine_id == NULL)
|
if (conf->agent->engine_id == NULL)
|
||||||
return -1;
|
return -1;
|
||||||
|
13
src/proxy.c
13
src/proxy.c
@ -407,6 +407,7 @@ void free_proxy(struct proxy *p)
|
|||||||
|
|
||||||
stktable_deinit(p->table);
|
stktable_deinit(p->table);
|
||||||
ha_free(&p->table);
|
ha_free(&p->table);
|
||||||
|
ha_free(&p->per_tgrp);
|
||||||
|
|
||||||
HA_RWLOCK_DESTROY(&p->lbprm.lock);
|
HA_RWLOCK_DESTROY(&p->lbprm.lock);
|
||||||
HA_RWLOCK_DESTROY(&p->lock);
|
HA_RWLOCK_DESTROY(&p->lock);
|
||||||
@ -1463,6 +1464,18 @@ void init_new_proxy(struct proxy *p)
|
|||||||
proxy_preset_defaults(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>. */
|
/* Preset default settings onto proxy <defproxy>. */
|
||||||
void proxy_preset_defaults(struct proxy *defproxy)
|
void proxy_preset_defaults(struct proxy *defproxy)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user