Skip to content

Commit

Permalink
quic/qlog: create log files with O_EXCL
Browse files Browse the repository at this point in the history
Avoid confusing log corruption if two loggers try to write
to the same file simultaneously.

Change-Id: I3bfbcf56aa55c778ada0178d7c662c414878c9d1
Reviewed-on: https://go-review.googlesource.com/c/net/+/545577
Reviewed-by: Jonathan Amsterdam <jba@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
  • Loading branch information
neild committed Dec 18, 2023
1 parent 1e59a7e commit 2b416c3
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion internal/quic/qlog/qlog.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ func newTraceWriter(opts HandlerOptions, info TraceInfo) (io.WriteCloser, error)
if !filepath.IsLocal(filename) {
return nil, errors.New("invalid trace filename")
}
w, err = os.Create(filepath.Join(opts.Dir, filename))
w, err = os.OpenFile(filepath.Join(opts.Dir, filename), os.O_CREATE|os.O_EXCL|os.O_WRONLY, 0666)
} else {
err = errors.New("no log destination")
}
Expand Down

0 comments on commit 2b416c3

Please sign in to comment.