mirror of
http://git.haproxy.org/git/haproxy.git
synced 2026-02-10 14:52:50 +02:00
MEDIUM: server: extend refcount for all servers
In a future patch, it will be possible to remove at runtime every servers, both static and dynamic. This requires to extend the server refcount for all instances. First, refcount manipulation functions have been renamed to better express the API usage. * srv_refcount_use -> srv_take The refcount is always initialize to 1 on the server creation in new_server. It's also incremented for each check/agent configured on a server instance. * free_server -> srv_drop This decrements the refcount and if null, the server is freed, so code calling it must not use the server reference after it. As a bonus, this function now returns the next server instance. This is useful when calling on the server loop without having to save the next pointer before each invocation. In these functions, remove the checks that prevent refcount on non-dynamic servers. Each reference to "dynamic" in variable/function naming have been eliminated as well.
This commit is contained in:
11
src/stats.c
11
src/stats.c
@@ -3113,17 +3113,15 @@ int stats_dump_proxy_to_buffer(struct stream_interface *si, struct htx *htx,
|
||||
case STAT_PX_ST_SV:
|
||||
/* obj2 points to servers list as initialized above.
|
||||
*
|
||||
* A dynamic server may be removed during the stats dumping.
|
||||
* A server may be removed during the stats dumping.
|
||||
* Temporarily increment its refcount to prevent its
|
||||
* anticipated cleaning. Call free_server to release it.
|
||||
*/
|
||||
for (; appctx->ctx.stats.obj2 != NULL;
|
||||
appctx->ctx.stats.obj2 =
|
||||
(!(sv->flags & SRV_F_DYNAMIC)) ? sv->next : free_server(sv)) {
|
||||
appctx->ctx.stats.obj2 = srv_drop(sv)) {
|
||||
|
||||
sv = appctx->ctx.stats.obj2;
|
||||
if (sv->flags & SRV_F_DYNAMIC)
|
||||
srv_use_dynsrv(sv);
|
||||
srv_take(sv);
|
||||
|
||||
if (htx) {
|
||||
if (htx_almost_full(htx))
|
||||
@@ -3136,8 +3134,7 @@ int stats_dump_proxy_to_buffer(struct stream_interface *si, struct htx *htx,
|
||||
|
||||
if (appctx->ctx.stats.flags & STAT_BOUND) {
|
||||
if (!(appctx->ctx.stats.type & (1 << STATS_TYPE_SV))) {
|
||||
if (sv->flags & SRV_F_DYNAMIC)
|
||||
free_server(appctx->ctx.stats.obj2);
|
||||
srv_drop(sv);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user