MINOR: server: return the next srv instance on free_server
As a convenience, return the next server instance from servers list on
free_server.
This is particularily useful when using this function on the servers
list without having to save of the next pointer before calling it.
(cherry picked from commit f5c1e12e44e1caa0185e063daf00fb8841c2ed3d)
[ad: updated context: remove uneeded condition on srv]
Signed-off-by: Amaury Denoyelle <adenoyelle@haproxy.com>
diff --git a/src/server.c b/src/server.c
index f2bd853..3fa7896 100644
--- a/src/server.c
+++ b/src/server.c
@@ -2220,16 +2220,23 @@
/* Deallocate a server <srv> and its member. <srv> must be allocated. For
* dynamic servers, its refcount is decremented first. The free operations are
* conducted only if the refcount is nul, unless the process is stopping.
+ *
+ * As a convenience, <srv.next> is returned if srv is not NULL. It may be useful
+ * when calling free_server on the list of servers.
*/
-void free_server(struct server *srv)
+struct server *free_server(struct server *srv)
{
+ struct server *next = NULL;
+
+ next = srv->next;
+
/* For dynamic servers, decrement the reference counter. Only free the
* server when reaching zero.
*/
if (likely(!(global.mode & MODE_STOPPING))) {
if (srv->flags & SRV_F_DYNAMIC) {
if (srv_release_dynsrv(srv))
- return;
+ goto end;
}
}
@@ -2259,6 +2266,9 @@
free(srv);
srv = NULL;
+
+ end:
+ return next;
}
/*