From 714a3bc3da1070700a972ea8adbcc36e2bceadf6 Mon Sep 17 00:00:00 2001 From: Sochin Jiang Date: Tue, 24 Nov 2020 16:36:45 +0800 Subject: [PATCH] lib/iscsi: unregister login timeout timer in right place In commit 9eefbc, we've fixed an iscsi connection leak problem( use telnet ${ip} ${port} to reproduce), that a connection without login handshake will be left forever with 'invalid' state. Here, to avoid killing normal connections by mistake, we need to unregister login timeout timer in two right places: 1) immediately after login timeout happened 2) when we receive login pdu instead of login success(login may fail because all kinds of reasons: ACL...) Signed-off-by: Sochin Jiang Change-Id: I55bbc1c6ac6d2e0b6545b9f7d802ba057b2a09dc Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/5209 Community-CI: Mellanox Build Bot Tested-by: SPDK CI Jenkins Reviewed-by: Jim Harris Reviewed-by: Shuhei Matsumoto --- lib/iscsi/conn.c | 1 + lib/iscsi/iscsi.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/iscsi/conn.c b/lib/iscsi/conn.c index f07c3767d..4b12e56cc 100644 --- a/lib/iscsi/conn.c +++ b/lib/iscsi/conn.c @@ -178,6 +178,7 @@ login_timeout(void *arg) if (conn->state < ISCSI_CONN_STATE_EXITING) { conn->state = ISCSI_CONN_STATE_EXITING; } + spdk_poller_unregister(&conn->login_timer); return SPDK_POLLER_BUSY; } diff --git a/lib/iscsi/iscsi.c b/lib/iscsi/iscsi.c index 625129c48..89c5a62f7 100644 --- a/lib/iscsi/iscsi.c +++ b/lib/iscsi/iscsi.c @@ -1148,7 +1148,6 @@ iscsi_conn_login_pdu_success_complete(void *arg) { struct spdk_iscsi_conn *conn = arg; - spdk_poller_unregister(&conn->login_timer); if (conn->state >= ISCSI_CONN_STATE_EXITING) { /* Connection is being exited before this callback is executed. */ @@ -2226,6 +2225,7 @@ iscsi_pdu_payload_op_login(struct spdk_iscsi_conn *conn, struct spdk_iscsi_pdu * return 0; } + spdk_poller_unregister(&conn->login_timer); rsp_pdu = conn->login_rsp_pdu; reqh = (struct iscsi_bhs_login_req *)&pdu->bhs;