fix: prevent deadlock in SessionData.Clear method (#114)

Move mutex unlock before calling Save() to prevent potential deadlock
when Save() method needs to acquire the same mutex.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-authored-by: Claude <[email protected]>
This commit is contained in:
Yuval Bar-On
2026-02-16 15:02:33 +00:00
committed by GitHub
co-authored by Claude
parent de4b4d7258
commit 249dcad1b3
+3 -2
View File
@@ -1548,9 +1548,10 @@ func (sd *SessionData) Clear(r *http.Request, w http.ResponseWriter) error {
}() }()
sd.sessionMutex.Lock() sd.sessionMutex.Lock()
defer sd.sessionMutex.Unlock()
sd.clearAllSessionData(r, true) sd.clearAllSessionData(r, true)
// Release the lock before calling Save to prevent deadlock
sd.sessionMutex.Unlock()
// This is primarily for testing - in production w will often be nil // This is primarily for testing - in production w will often be nil
var err error var err error