fix: defer session cleanup to connection close, not logout
Move session cleanup out of iscsiExecLogout() and keep it only in the CONN_STATE_CLOSE handler. The logout response must be fully sent before the session is removed; cleaning up during logout causes the daemon to hang because subsequent operations reference a nil session. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -575,8 +575,9 @@ func (s *ISCSITargetDriver) iscsiExecLogout(conn *iscsiConnection) error {
|
||||
} else {
|
||||
conn.resp.ExpCmdSN = conn.session.ExpCmdSN
|
||||
conn.resp.MaxCmdSN = conn.session.ExpCmdSN + conn.session.MaxQueueCommand
|
||||
s.removeConnectionFromSession(conn)
|
||||
}
|
||||
// Session cleanup is deferred to CONN_STATE_CLOSE in handler(),
|
||||
// because the logout response must be sent before the session is removed.
|
||||
IPMutex.Lock()
|
||||
remoteIP := strings.Split(conn.conn.RemoteAddr().String(), ":")[0]
|
||||
if CurrentHostIP == remoteIP {
|
||||
|
||||
Reference in New Issue
Block a user