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 <changpeng.liu@intel.com>
This commit is contained in:
Changpeng Liu 2016-12-08 14:21:10 +08:00 committed by Daniel Verkamp
parent 6db4f2b072
commit df06c0d2af
2 changed files with 7 additions and 2 deletions

View File

@ -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) {

View File

@ -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 {