Source File
file.go
Belonging Package
github.com/polarsignals/wal/fs
// Copyright (c) HashiCorp, Inc// SPDX-License-Identifier: MPL-2.0package fsimport ()var _ types.WritableFile = &File{}// File wraps an os.File and implements types.WritableFile. It ensures that the// first time Sync is called on the file, that the parent directory is also// Fsynced to ensure a crash won't cause the FS to forget the file is there.//// Postponing this allows us to ensure that we do the minimum necessary fsyncs// but still ensure all required fsyncs are done by the time we acknowledge// committed data in the new file.type File struct {new uint32 // atomically accessed, keep it aligned!dir stringos.File}// Sync calls fsync on the underlying file. If this is the first call to Sync// since creation it also fsyncs the parent dir.func ( *File) () error {// Sync the underlying fileif := .File.Sync(); != nil {return}:= atomic.SwapUint32(&.new, 1)if == 0 {return syncDir(.dir)}return nil}
![]() |
The pages are generated with Golds v0.8.2. (GOOS=linux GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds. |