[MEDIUM] the stats dump FSM was buggy and looped on dispatch instances.

It has been rewritten and now supports an initialization state. It now also
prevents from dumping stopped(disabled) listeners and it is possible to
specify a scope with a list of proxies that are allowed to be dumped from
the one being configured ('.' meaning "this one"). The 'stats' entry can
be configured from the 'defaults' instance and it is correctly flushed
from proxies which redefine it.
This commit is contained in:
willy tarreau
2006-05-21 14:46:15 +02:00
parent fac1a86495
commit 1f431b5851
4 changed files with 225 additions and 88 deletions

View File

@@ -160,3 +160,45 @@ struct uri_auth *stats_add_auth(struct uri_auth **root, char *auth)
return NULL;
}
/*
* Returns a default uri_auth with a <scope> entry added to the list of
* allowed scopes. If a matching entry is found, no update will be performed.
* Uses the pointer provided if not NULL and not initialized.
*/
struct uri_auth *stats_add_scope(struct uri_auth **root, char *scope)
{
struct uri_auth *u;
char *new_name;
struct stat_scope *old_scope, **scope_list;
if ((u = stats_check_init_uri_auth(root)) == NULL)
goto out;
scope_list = &u->scope;
while ((old_scope = *scope_list)) {
if (!strcmp(old_scope->px_id, scope))
break;
scope_list = &old_scope->next;
}
if (!old_scope) {
if ((new_name = strdup(scope)) == NULL)
goto out_u;
if ((old_scope = (struct stat_scope *)calloc(1, sizeof(*old_scope))) == NULL)
goto out_name;
old_scope->px_id = new_name;
old_scope->px_len = strlen(new_name);
*scope_list = old_scope;
}
return u;
out_name:
free(new_name);
out_u:
free(u);
out:
return NULL;
}