fix: call released on ctx done

This commit is contained in:
Derrick Hammer 2024-01-20 11:06:50 -05:00
parent 112fbb4c51
commit 6bbfac661a
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
1 changed files with 4 additions and 0 deletions

View File

@ -67,6 +67,10 @@ func (l *Lock) Lock(ctx context.Context, requestUnlock func()) error {
select {
case <-ctx.Done():
err := l.released()
if err != nil {
return err
}
// Context expired, so we return a timeout
return tusd.ErrLockTimeout
case <-time.After(l.acquirerPollInterval):