]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MEDIUM: check: No longer shutdown the connection in .wake callback function
authorChristopher Faulet <cfaulet@haproxy.com>
Wed, 18 May 2022 12:35:49 +0000 (14:35 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Thu, 19 May 2022 08:12:38 +0000 (10:12 +0200)
The connection is already closed by the health-check itself. Thus there is
now reason to duplicate this part in the .wake callback function. It is
enough to wake the health-check and wait.

src/check.c

index 2da39af4d485dc2dc80f91d83d56974b5201aeac..792c9aec6fb863ff0bbcf96ac8f796e38948faf7 100644 (file)
@@ -1024,6 +1024,9 @@ static int wake_srv_chk(struct conn_stream *cs)
        int ret = 0;
 
        TRACE_ENTER(CHK_EV_HCHK_WAKE, check);
+       if (check->result != CHK_RES_UNKNOWN)
+               goto end;
+
        if (check->server)
                HA_SPIN_LOCK(SERVER_LOCK, &check->server->lock);
        else
@@ -1048,21 +1051,9 @@ static int wake_srv_chk(struct conn_stream *cs)
        }
 
        if (check->result != CHK_RES_UNKNOWN || ret == -1) {
-               /* Check complete or aborted. If connection not yet closed do it
-                * now and wake the check task up to be sure the result is
-                * handled ASAP. */
+               /* Check complete or aborted. Wake the check task up to be sure
+                * the result is handled ASAP. */
                ret = -1;
-               if (conn)  {
-                       cs_conn_drain_and_shut(cs);
-                       if (check->wait_list.events)
-                               conn->mux->unsubscribe(cs, check->wait_list.events, &check->wait_list);
-               }
-
-               /* We may have been scheduled to run, and the
-                * I/O handler expects to have a cs, so remove
-                * the tasklet
-                */
-               tasklet_remove_from_tasklet_list(check->wait_list.tasklet);
                task_wakeup(check->task, TASK_WOKEN_IO);
        }
 
@@ -1071,6 +1062,7 @@ static int wake_srv_chk(struct conn_stream *cs)
        else
                HA_SPIN_UNLOCK(EMAIL_ALERTS_LOCK, &q->lock);
 
+  end:
        TRACE_LEAVE(CHK_EV_HCHK_WAKE, check);
        return ret;
 }