Additional potential race condition on os.Readdir

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
This commit is contained in:
Daniel J Walsh
2024-08-12 11:12:54 -04:00
parent 4f2d98f228
commit 25d66d97d2

View File

@ -1,7 +1,9 @@
package file
import (
"errors"
"fmt"
"io/fs"
"os"
"path/filepath"
"strconv"
@ -138,7 +140,9 @@ func (locks *FileLocks) DeallocateAllLocks() error {
p := filepath.Join(locks.lockPath, f.Name())
err := os.Remove(p)
if err != nil {
lastErr = err
if errors.Is(err, fs.ErrNotExist) {
continue
}
logrus.Errorf("Deallocating lock %s", p)
}
}