MEDIUM: checks: do not allocate a permanent connection anymore

Health check currently cheat, they allocate a connection upon startup and never
release it, it's only recycled. The problem with doing this is that this code
is preventing the connection code from evolving towards multiplexing.

This code ensures that it's safe for the checks to run without a connection
all the time. Given that the code heavily relies on CO_FL_ERROR to signal
check errors, it is not trivial but in practice this is the principle adopted
here :

  - the connection is not allocated anymore on startup

  - new checks are not supposed to have a connection, so an attempt is made
    to allocate this connection in the check task's context. If it fails,
    the check is aborted on a resource error, and the rare code on this path
    verifying the connection was adjusted to check for its existence (in
    practice, avoid to close it)

  - returning checks necessarily have a valid connection (which may possibly
    be closed).

  - a "tcp-check connect" rule tries to allocate a new connection before
    releasing the previous one (but after closing it), so that if it fails,
    it still keeps the previous connection in a closed state. This ensures
    a connection is always valid here

Now it works well on all tested cases (regular and TCP checks, even with
multiple reconnections), including when the connection is forced to NULL or
randomly allocated.
1 file changed