From df06c0d2af891a4abdbb6b6013c2e5a3a70ee4e3 Mon Sep 17 00:00:00 2001 From: Changpeng Liu Date: Thu, 8 Dec 2016 14:21:10 +0800 Subject: [PATCH] iscsi: drop the connection when quit the process We cannot quit the process when user did not Logout from the session, because the active connections always bigger than zero. User cannot use Ctrl+C to quit SPDK iSCSI target. Add a new state to connection to avoid destruct connection more than once. Change-Id: I8efa79aa47534bd6ead965713769f751d9802e47 Signed-off-by: Changpeng Liu --- lib/iscsi/conn.c | 8 ++++++-- lib/iscsi/iscsi.h | 1 + 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/iscsi/conn.c b/lib/iscsi/conn.c index dbf5c6bdc..5ad238c85 100644 --- a/lib/iscsi/conn.c +++ b/lib/iscsi/conn.c @@ -592,7 +592,7 @@ void spdk_iscsi_conn_destruct(struct spdk_iscsi_conn *conn) struct spdk_iscsi_tgt_node *target; int rc; - conn->state = ISCSI_CONN_STATE_EXITING; + conn->state = ISCSI_CONN_STATE_EXITED; if (conn->sess != NULL && conn->pending_task_cnt > 0) { target = conn->sess->target; @@ -1239,9 +1239,13 @@ spdk_iscsi_conn_execute(struct spdk_iscsi_conn *conn) uint64_t tsc; bool conn_active = false; - if (conn->state == ISCSI_CONN_STATE_EXITING) { + if (conn->state == ISCSI_CONN_STATE_EXITED) { return -1; } + + if (conn->state == ISCSI_CONN_STATE_EXITING) { + goto conn_exit; + } /* Check for nop interval expiration */ rc = spdk_iscsi_conn_handle_nop(conn); if (rc < 0) { diff --git a/lib/iscsi/iscsi.h b/lib/iscsi/iscsi.h index b6d0716c4..45ebb81c6 100644 --- a/lib/iscsi/iscsi.h +++ b/lib/iscsi/iscsi.h @@ -195,6 +195,7 @@ enum iscsi_connection_state { ISCSI_CONN_STATE_RUNNING = 1, ISCSI_CONN_STATE_LOGGED_OUT = 2, ISCSI_CONN_STATE_EXITING = 3, + ISCSI_CONN_STATE_EXITED = 4, }; enum iscsi_chap_phase {