MINOR: server: implement a refcount for dynamic servers

It is necessary to have a refcount mechanism on dynamic servers to be
able to enable check support. Indeed, when deleting a dynamic server
with check activated, the check will be asynchronously removed. This is
mandatory to properly free the check resources in a thread-safe manner.
The server instance must be kept alive for this.

(cherry picked from commit d6b7080cecee3450bbad8fbd5d9b100be0a2d13d)
[ad: move refcount increment in 'add server' handler, or else a leak
 might be present in case on error return from the handler with the
 server already allocated; this bug is not present in upstream because
 the increment is now done in new_server directly.]
Signed-off-by: Amaury Denoyelle <adenoyelle@haproxy.com>
2 files changed