iSCSI: set a connection to EXISTING STATE in condition

If the connection is already in exiting or exited
status, we should not set it again. And this
could prevent the coredump.

Change-Id: Ia506d13b12c3a6cb5619d65e4b3353b149a85947
Signed-off-by: Ziye Yang <optimistyzy@gmail.com>
Reviewed-on: https://review.gerrithub.io/421668
Chandler-Test-Pool: SPDK Automated Test System <sys_sgsw@intel.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
This commit is contained in:
Ziye Yang 2018-08-09 09:36:20 +08:00 committed by Jim Harris
parent a257328d69
commit 1ba87aba31

View File

@ -690,7 +690,13 @@ void spdk_shutdown_iscsi_conns(void)
if (conn == NULL) {
continue;
}
conn->state = ISCSI_CONN_STATE_EXITING;
/* Do not set conn->state if the connection has already started exiting.
* This ensures we do not move a connection from EXITED state back to EXITING.
*/
if (conn->state < ISCSI_CONN_STATE_EXITING) {
conn->state = ISCSI_CONN_STATE_EXITING;
}
}
pthread_mutex_unlock(&g_conns_mutex);
@ -749,7 +755,13 @@ spdk_iscsi_drop_conns(struct spdk_iscsi_conn *conn, const char *conn_match,
}
SPDK_DEBUGLOG(SPDK_LOG_ISCSI, "CID=%u\n", xconn->cid);
xconn->state = ISCSI_CONN_STATE_EXITING;
/* Do not set xconn->state if the connection has already started exiting.
* This ensures we do not move a connection from EXITED state back to EXITING.
*/
if (xconn->state < ISCSI_CONN_STATE_EXITING) {
xconn->state = ISCSI_CONN_STATE_EXITING;
}
num++;
}
}