fix: extract clearHostIP helper and restore IP cleanup on close
Restore CurrentHostIP cleanup on connection close (needed for blockMultipleHostLogin feature). Extract to clearHostIP helper to reduce duplication. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -359,12 +359,7 @@ func (s *ISCSITargetDriver) handler(events byte, conn *iscsiConnection) {
|
|||||||
log.Warningf("iscsi connection[%d] closed", conn.cid)
|
log.Warningf("iscsi connection[%d] closed", conn.cid)
|
||||||
s.removeConnectionFromSession(conn)
|
s.removeConnectionFromSession(conn)
|
||||||
conn.close()
|
conn.close()
|
||||||
IPMutex.Lock()
|
s.clearHostIP(conn)
|
||||||
remoteIP := strings.Split(conn.conn.RemoteAddr().String(), ":")[0]
|
|
||||||
if CurrentHostIP == remoteIP {
|
|
||||||
CurrentHostIP = ""
|
|
||||||
}
|
|
||||||
IPMutex.Unlock()
|
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
@@ -376,15 +371,19 @@ func (s *ISCSITargetDriver) handler(events byte, conn *iscsiConnection) {
|
|||||||
log.Warningf("iscsi connection[%d] closed", conn.cid)
|
log.Warningf("iscsi connection[%d] closed", conn.cid)
|
||||||
s.removeConnectionFromSession(conn)
|
s.removeConnectionFromSession(conn)
|
||||||
conn.close()
|
conn.close()
|
||||||
IPMutex.Lock()
|
s.clearHostIP(conn)
|
||||||
remoteIP := strings.Split(conn.conn.RemoteAddr().String(), ":")[0]
|
|
||||||
if CurrentHostIP == remoteIP {
|
|
||||||
CurrentHostIP = ""
|
|
||||||
}
|
|
||||||
IPMutex.Unlock()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *ISCSITargetDriver) clearHostIP(conn *iscsiConnection) {
|
||||||
|
IPMutex.Lock()
|
||||||
|
remoteIP := strings.Split(conn.conn.RemoteAddr().String(), ":")[0]
|
||||||
|
if CurrentHostIP == remoteIP {
|
||||||
|
CurrentHostIP = ""
|
||||||
|
}
|
||||||
|
IPMutex.Unlock()
|
||||||
|
}
|
||||||
|
|
||||||
func (s *ISCSITargetDriver) rxHandler(conn *iscsiConnection) {
|
func (s *ISCSITargetDriver) rxHandler(conn *iscsiConnection) {
|
||||||
var (
|
var (
|
||||||
hdigest uint = 0
|
hdigest uint = 0
|
||||||
|
|||||||
Reference in New Issue
Block a user