Skip to content

Commit 58a1122

Browse files
committed
internal/counter: use ReadMapped from counter.Read
counter.Read, which is the implementation of countertest.ReadCounter, was using os.ReadFile to read the counter file's contents. As we have seen elsewhere, this may lead to synchronization issues. To ensure we observe all active counts we should read via mmap. For this reason, counter.ReadFile was already using the ReadMapped helper. Update Read to do the same. I believe this fixes two test failures that we've observed in gopls. For golang/go#68659 For golang/go#69132 Change-Id: I8d09b98fa2e69ac1b9a7580b061d4b266130773c Reviewed-on: https://go-review.googlesource.com/c/telemetry/+/625496 Auto-Submit: Robert Findley <rfindley@google.com> Reviewed-by: Alan Donovan <adonovan@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
1 parent bf5a09b commit 58a1122

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

internal/counter/counter.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ func readFile(f *file) (*File, error) {
341341
return nil, fmt.Errorf("counter has no mapped file")
342342
}
343343
name := current.f.Name()
344-
data, err := os.ReadFile(name)
344+
data, err := ReadMapped(name)
345345
if err != nil {
346346
return nil, fmt.Errorf("failed to read from file: %v", err)
347347
}

0 commit comments

Comments
 (0)