From 3d5e1218429f7c06122ad612bbda561030706cab Mon Sep 17 00:00:00 2001 From: Christopher Faulet Date: Thu, 28 May 2020 14:34:02 +0200 Subject: [PATCH] MINOR: checks: I/O callback function only rely on the data layer wake callback Most of code in event_srv_chk_io() function is inherited from the checks before the recent refactoring. Now, it is enough to only call wake_srv_chk(). Since the refactoring, the removed code is dead and never called. wake_srv_chk() may only return 0 if tcpcheck_main() returns 0 and the check status is unknown (CHK_RES_UNKNOWN). When this happens, nothing is performed in event_srv_chk_io(). --- src/checks.c | 45 +-------------------------------------------- 1 file changed, 1 insertion(+), 44 deletions(-) diff --git a/src/checks.c b/src/checks.c index 9b4e41c35..b5270b07d 100644 --- a/src/checks.c +++ b/src/checks.c @@ -3467,51 +3467,8 @@ static struct task *event_srv_chk_io(struct task *t, void *ctx, unsigned short s { struct check *check = ctx; struct conn_stream *cs = check->cs; - struct email_alertq *q = container_of(check, typeof(*q), check); - int ret = 0; - if (!(check->wait_list.events & SUB_RETRY_SEND)) - ret = wake_srv_chk(cs); - if (ret == 0 && !(check->wait_list.events & SUB_RETRY_RECV)) { - if (check->server) - HA_SPIN_LOCK(SERVER_LOCK, &check->server->lock); - else - HA_SPIN_LOCK(EMAIL_ALERTS_LOCK, &q->lock); - - if (unlikely(check->result == CHK_RES_FAILED)) { - /* collect possible new errors */ - if (cs->conn->flags & CO_FL_ERROR || cs->flags & CS_FL_ERROR) - chk_report_conn_err(check, 0, 0); - - /* Reset the check buffer... */ - b_reset(&check->bi); - - /* Close the connection... We still attempt to nicely close if, - * for instance, SSL needs to send a "close notify." Later, we perform - * a hard close and reset the connection if some data are pending, - * otherwise we end up with many TIME_WAITs and eat all the source port - * range quickly. To avoid sending RSTs all the time, we first try to - * drain pending data. - */ - /* Call cs_shutr() first, to add the CO_FL_SOCK_RD_SH flag on the - * connection, to make sure cs_shutw() will not lead to a shutdown() - * that would provoke TIME_WAITs. - */ - cs_shutr(cs, CS_SHR_DRAIN); - cs_shutw(cs, CS_SHW_NORMAL); - - /* OK, let's not stay here forever */ - if (check->result == CHK_RES_FAILED) - cs->conn->flags |= CO_FL_ERROR; - - task_wakeup(t, TASK_WOKEN_IO); - } - - if (check->server) - HA_SPIN_UNLOCK(SERVER_LOCK, &check->server->lock); - else - HA_SPIN_UNLOCK(EMAIL_ALERTS_LOCK, &q->lock); - } + wake_srv_chk(cs); return NULL; }