check_release_buf(check, &check->bi);
check_release_buf(check, &check->bo);
- _HA_ATOMIC_DEC(&th_ctx->running_checks);
+
+ if (unlikely(LIST_INLIST(&check->check_queue))) {
+ /*
+ * If that check is still queued, and we're about to
+ * purge it, then remove it from the queue, as it is
+ * about to be freed.
+ * This can happen if a server is deleted while the check
+ * is queued.
+ */
+ if (check->state & CHK_ST_PURGE)
+ LIST_DEL_INIT(&check->check_queue);
+ }
+ else
+ _HA_ATOMIC_DEC(&th_ctx->running_checks);
_HA_ATOMIC_DEC(&th_ctx->active_checks);
check->state &= ~(CHK_ST_INPROGRESS|CHK_ST_IN_ALLOC|CHK_ST_OUT_ALLOC);
check->state &= ~CHK_ST_READY;
ha_free(&check->tcpcheck);
}
+ LIST_DEL_INIT(&check->check_queue);
pool_free(pool_head_uniqueid, istptr(check->unique_id));
check->unique_id = IST_NULL;
ha_free(&check->pool_conn_name);