forked from TrueCloudLab/frostfs-s3-gw
[#165] Cancel context in outdated list session
Signed-off-by: Denis Kirillov <d.kirillov@yadro.com>
This commit is contained in:
parent
4e15452853
commit
88f1acbdfc
7 changed files with 69 additions and 15 deletions
10
api/cache/listsession.go
vendored
10
api/cache/listsession.go
vendored
|
@ -55,7 +55,9 @@ func NewListSessionCache(config *Config) *ListSessionCache {
|
|||
zap.String("expected", fmt.Sprintf("%T", session)))
|
||||
}
|
||||
|
||||
// todo session.Cancel()
|
||||
if !session.Acquired.Load() {
|
||||
session.Cancel()
|
||||
}
|
||||
}).Build()
|
||||
return &ListSessionCache{cache: gc, logger: config.Logger}
|
||||
}
|
||||
|
@ -79,6 +81,12 @@ func (l *ListSessionCache) GetListSession(key ListSessionKey) *data.ListSession
|
|||
|
||||
// PutListSession puts a list of object versions to cache.
|
||||
func (l *ListSessionCache) PutListSession(key ListSessionKey, session *data.ListSession) error {
|
||||
s := l.GetListSession(key)
|
||||
if s != nil && s != session {
|
||||
if !s.Acquired.Load() {
|
||||
s.Cancel()
|
||||
}
|
||||
}
|
||||
return l.cache.Set(key, session)
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue