Skip to content

Commit 2b416c3

Browse files
committed
quic/qlog: create log files with O_EXCL
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 <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]>
1 parent 1e59a7e commit 2b416c3

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

internal/quic/qlog/qlog.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ func newTraceWriter(opts HandlerOptions, info TraceInfo) (io.WriteCloser, error)
180180
if !filepath.IsLocal(filename) {
181181
return nil, errors.New("invalid trace filename")
182182
}
183-
w, err = os.Create(filepath.Join(opts.Dir, filename))
183+
w, err = os.OpenFile(filepath.Join(opts.Dir, filename), os.O_CREATE|os.O_EXCL|os.O_WRONLY, 0666)
184184
} else {
185185
err = errors.New("no log destination")
186186
}

0 commit comments

Comments
 (0)