mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2026-01-15 05:41:16 +01:00
MINOR: receiver: Dynamically alloc the "members" field of shard_info
Instead of always allocating MAX_TGROUPS members, allocate them dynamically, using the number of thread groups we'll use, so that increasing MAX_TGROUPS will not have a huge impact on the structure size.
This commit is contained in:
parent
96faf71f87
commit
c0f64fc36a
@ -65,7 +65,7 @@ struct shard_info {
|
||||
uint nbgroups; /* number of groups in this shard (=#rx); Zero = unused. */
|
||||
uint nbthreads; /* number of threads in this shard (>=nbgroups) */
|
||||
struct receiver *ref; /* first one, reference for FDs to duplicate */
|
||||
struct receiver *members[MAX_TGROUPS]; /* all members of the shard (one per thread group) */
|
||||
struct receiver **members; /* all members of the shard (one per thread group) */
|
||||
};
|
||||
|
||||
/* This describes a receiver with all its characteristics (address, options, etc) */
|
||||
|
||||
@ -879,6 +879,11 @@ struct shard_info *shard_info_attach(struct receiver *rx, struct shard_info *si)
|
||||
return NULL;
|
||||
|
||||
si->ref = rx;
|
||||
si->members = calloc(global.nbtgroups, sizeof(*si->members));
|
||||
if (si->members == NULL) {
|
||||
free(si);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
rx->shard_info = si;
|
||||
@ -921,8 +926,10 @@ void shard_info_detach(struct receiver *rx)
|
||||
si->members[si->nbgroups] = NULL;
|
||||
si->ref = si->members[0];
|
||||
|
||||
if (!si->nbgroups)
|
||||
if (!si->nbgroups) {
|
||||
free(si->members);
|
||||
free(si);
|
||||
}
|
||||
}
|
||||
|
||||
/* clones listener <src> and returns the new one. All dynamically allocated
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user