REORG: vars: move the "proc" scope variables out of the global struct
The presence of this field causes a long dependency chain because almost
everyone includes global-t.h, and vars include sample_data which include
some system includes as well as HTTP parts.
There is absolutely no reason for having the process-wide variables in
the global struct, let's just move them into vars.c and vars.h. This
reduces from ~190k to ~170k the preprocessed output of version.c.
diff --git a/src/haproxy.c b/src/haproxy.c
index 76fe08c..3de53bf 100644
--- a/src/haproxy.c
+++ b/src/haproxy.c
@@ -1521,7 +1521,7 @@
hlua_init();
/* Initialize process vars */
- vars_init(&global.vars, SCOPE_PROC);
+ vars_init(&proc_vars, SCOPE_PROC);
global.tune.options |= GTUNE_USE_SELECT; /* select() is always available */
#if defined(USE_POLL)
@@ -2553,7 +2553,7 @@
free(tff);
}
- vars_prune(&global.vars, NULL, NULL);
+ vars_prune(&proc_vars, NULL, NULL);
pool_destroy_all();
deinit_pollers();
} /* end deinit() */
diff --git a/src/vars.c b/src/vars.c
index 202a9ae..572b5f5 100644
--- a/src/vars.c
+++ b/src/vars.c
@@ -21,6 +21,9 @@
/* This contains a pool of struct vars */
DECLARE_STATIC_POOL(var_pool, "vars", sizeof(struct var));
+/* list of variables for the process scope. */
+struct vars proc_vars THREAD_ALIGNED(64);
+
/* This array contain all the names of all the HAProxy vars.
* This permits to identify two variables name with
* only one pointer. It permits to not using strdup() for
@@ -47,7 +50,7 @@
{
switch (scope) {
case SCOPE_PROC:
- return &global.vars;
+ return &proc_vars;
case SCOPE_SESS:
return sess ? &sess->vars : NULL;
case SCOPE_CHECK: {
@@ -91,7 +94,7 @@
_HA_ATOMIC_ADD(&sess->vars.size, size);
/* fall through */
case SCOPE_PROC:
- _HA_ATOMIC_ADD(&global.vars.size, size);
+ _HA_ATOMIC_ADD(&proc_vars.size, size);
_HA_ATOMIC_ADD(&var_global_size, size);
}
}
@@ -128,7 +131,7 @@
return 0;
/* fall through */
case SCOPE_PROC:
- if (var_proc_limit && global.vars.size + size > var_proc_limit)
+ if (var_proc_limit && proc_vars.size + size > var_proc_limit)
return 0;
if (var_global_limit && var_global_size + size > var_global_limit)
return 0;
@@ -187,7 +190,7 @@
HA_RWLOCK_WRUNLOCK(VARS_LOCK, &vars->rwlock);
_HA_ATOMIC_SUB(&vars->size, size);
- _HA_ATOMIC_SUB(&global.vars.size, size);
+ _HA_ATOMIC_SUB(&proc_vars.size, size);
_HA_ATOMIC_SUB(&var_global_size, size);
}