From 47d5ddb7ce02a6a8f94826a8e3472683ae18ec15 Mon Sep 17 00:00:00 2001 From: Shuhei Matsumoto Date: Tue, 15 Jan 2019 16:46:05 +0900 Subject: [PATCH] iscsi: Fix conflict by destructing connection and logout timeout During destructing a connection, if timeout of logout timer for the connection occurs, spdk_iscsi_conn_destruct() will be called again to the connection. Segmentation fault by multiple calls of spdk_iscsi_conn_destruct() have been observed when exiting one of the sesssions during IO tests for multiple sessions. Fix #574 Change-Id: I69873905486953bfb0cdb43b000b8e38ff9346ac Signed-off-by: Shuhei Matsumoto Reviewed-on: https://review.gerrithub.io/c/440466 Chandler-Test-Pool: SPDK Automated Test System Reviewed-by: Jim Harris Reviewed-by: Changpeng Liu Tested-by: SPDK CI Jenkins --- lib/iscsi/conn.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/iscsi/conn.c b/lib/iscsi/conn.c index 1550452d1..018753827 100644 --- a/lib/iscsi/conn.c +++ b/lib/iscsi/conn.c @@ -559,6 +559,11 @@ _spdk_iscsi_conn_check_pending_tasks(void *arg) void spdk_iscsi_conn_destruct(struct spdk_iscsi_conn *conn) { + /* If a connection is already in exited status, just return */ + if (conn->state >= ISCSI_CONN_STATE_EXITED) { + return; + } + conn->state = ISCSI_CONN_STATE_EXITED; if (conn->sess != NULL && conn->pending_task_cnt > 0) {