diff options
Diffstat (limited to 'src/os/file_plan9.go')
| -rw-r--r-- | src/os/file_plan9.go | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/src/os/file_plan9.go b/src/os/file_plan9.go index 656a3e0bb0..17026409eb 100644 --- a/src/os/file_plan9.go +++ b/src/os/file_plan9.go @@ -23,7 +23,7 @@ func fixLongPath(path string) string { // file is the real representation of *File. // The extra level of indirection ensures that no clients of os -// can overwrite this data, which could cause the cleanup +// can overwrite this data, which could cause the finalizer // to close the wrong file descriptor. type file struct { fdmu poll.FDMutex @@ -31,7 +31,6 @@ type file struct { name string dirinfo atomic.Pointer[dirInfo] // nil unless directory being read appendMode bool // whether file is opened for appending - cleanup runtime.Cleanup // cleanup closes the file when no longer referenced } // fd is the Plan 9 implementation of Fd. @@ -49,7 +48,7 @@ func newFileFromNewFile(fd uintptr, name string) *File { return nil } f := &File{&file{sysfd: fdi, name: name}} - f.cleanup = runtime.AddCleanup(f, func(f *file) { f.close() }, f.file) + runtime.SetFinalizer(f.file, (*file).close) return f } @@ -160,9 +159,8 @@ func (file *file) close() error { err := file.decref() - // There is no need for a cleanup at this point. File must be alive at the point - // where cleanup.stop is called. - file.cleanup.Stop() + // no need for a finalizer anymore + runtime.SetFinalizer(file, nil) return err } |
