fix: only destroy session if exists
The virtual session doesn't unconditionally call `Read` of the provider, which means it's possible for a session to not exists (created by the call to `Read`). To avoid that the call to `Destroy` fails with that the session does not exists, do also the exists check for `Destroy`.
This commit is contained in:
@@ -76,7 +76,10 @@ func (o *VirtualSessionProvider) Exist(sid string) bool {
|
|||||||
func (o *VirtualSessionProvider) Destroy(sid string) error {
|
func (o *VirtualSessionProvider) Destroy(sid string) error {
|
||||||
o.lock.Lock()
|
o.lock.Lock()
|
||||||
defer o.lock.Unlock()
|
defer o.lock.Unlock()
|
||||||
return o.provider.Destroy(sid)
|
if o.provider.Exist(sid) {
|
||||||
|
return o.provider.Destroy(sid)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Regenerate regenerates a session store from old session ID to new one.
|
// Regenerate regenerates a session store from old session ID to new one.
|
||||||
|
|||||||
Reference in New Issue
Block a user