Skip to content

Commit

Permalink
TempFile: document methods not concurrency-safe (#28)
Browse files Browse the repository at this point in the history
  • Loading branch information
peterbourgon committed Feb 26, 2021
1 parent ad9e5e5 commit 650fcb9
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions tempfile.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ type PendingFile struct {

// Cleanup is a no-op if CloseAtomicallyReplace succeeded, and otherwise closes
// and removes the temporary file.
//
// This method is not safe for concurrent use by multiple goroutines.
func (t *PendingFile) Cleanup() error {
if t.done {
return nil
Expand All @@ -105,6 +107,8 @@ func (t *PendingFile) Cleanup() error {
// the destination file with it, i.e., a concurrent open(2) call will either
// open the file previously located at the destination path (if any), or the
// just written file, but the file will always be present.
//
// This method is not safe for concurrent use by multiple goroutines.
func (t *PendingFile) CloseAtomicallyReplace() error {
// Even on an ordered file system (e.g. ext4 with data=ordered) or file
// systems with write barriers, we cannot skip the fsync(2) call as per
Expand Down

0 comments on commit 650fcb9

Please sign in to comment.