aboutsummaryrefslogtreecommitdiffhomepage
path: root/internal/lockedfile
diff options
context:
space:
mode:
authorOphestra <cat@gensokyo.uk>2026-02-18 20:00:32 +0900
committerOphestra <cat@gensokyo.uk>2026-02-18 20:00:32 +0900
commit3bfe99d3d855a03a806dc66c8c215ba69d2dd67b (patch)
tree32ae1a7b622d086f69f71b82fd969b95d6970d46 /internal/lockedfile
parent149dfbb6af2a777007e2a9d27207fdf74426078e (diff)
internal/lockedfile: keep objects alive while stopping cleanups
Fixes https://go.dev/issues/74780. Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'internal/lockedfile')
-rw-r--r--internal/lockedfile/internal/filelock/filelock.go8
-rw-r--r--internal/lockedfile/lockedfile.go5
2 files changed, 5 insertions, 8 deletions
diff --git a/internal/lockedfile/internal/filelock/filelock.go b/internal/lockedfile/internal/filelock/filelock.go
index d3733189..f0452f01 100644
--- a/internal/lockedfile/internal/filelock/filelock.go
+++ b/internal/lockedfile/internal/filelock/filelock.go
@@ -8,7 +8,6 @@
package filelock
import (
- "errors"
"io/fs"
)
@@ -74,10 +73,3 @@ func (lt lockType) String() string {
return "Unlock"
}
}
-
-// IsNotSupported returns a boolean indicating whether the error is known to
-// report that a function is not supported (possibly for a specific input).
-// It is satisfied by errors.ErrUnsupported as well as some syscall errors.
-func IsNotSupported(err error) bool {
- return errors.Is(err, errors.ErrUnsupported)
-}
diff --git a/internal/lockedfile/lockedfile.go b/internal/lockedfile/lockedfile.go
index 8bd2ffbe..f48124ff 100644
--- a/internal/lockedfile/lockedfile.go
+++ b/internal/lockedfile/lockedfile.go
@@ -94,6 +94,11 @@ func (f *File) Close() error {
err := closeFile(f.osFile.File)
f.cleanup.Stop()
+ // f may be dead at the moment after we access f.cleanup,
+ // so the cleanup can fire before Stop completes. Keep f
+ // alive while we call Stop. See the documentation for
+ // runtime.Cleanup.Stop.
+ runtime.KeepAlive(f)
return err
}