mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-11-27 13:51:00 +01:00
BUG/MINOR: state-file: do not store duplicates in the global tree
The global state file tree isn't configured for unique keys, so if an entry appears multiple times, e.g. due to a bogus script that concatenates entries multiple times, this will needlessly eat memory. Let's just drop duplicates. This should be backported to 2.1.
This commit is contained in:
parent
7d6a1fa311
commit
fd1aa01f72
@ -75,7 +75,7 @@ struct dict server_name_dict = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/* tree where global state_file is loaded */
|
/* tree where global state_file is loaded */
|
||||||
struct eb_root state_file = EB_ROOT;
|
struct eb_root state_file = EB_ROOT_UNIQUE;
|
||||||
|
|
||||||
int srv_downtime(const struct server *s)
|
int srv_downtime(const struct server *s)
|
||||||
{
|
{
|
||||||
@ -3632,7 +3632,12 @@ void apply_server_state(void)
|
|||||||
goto nextline;
|
goto nextline;
|
||||||
}
|
}
|
||||||
memcpy(st->name_name.key, trash.area, trash.data + 1);
|
memcpy(st->name_name.key, trash.area, trash.data + 1);
|
||||||
ebst_insert(&state_file, &st->name_name);
|
if (ebst_insert(&state_file, &st->name_name) != &st->name_name) {
|
||||||
|
/* this is a duplicate key, probably a hand-crafted file,
|
||||||
|
* drop it!
|
||||||
|
*/
|
||||||
|
goto nextline;
|
||||||
|
}
|
||||||
|
|
||||||
/* save line */
|
/* save line */
|
||||||
st->line = line;
|
st->line = line;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user