Skip to content

Commit

Permalink
[backport] fix(webconnectivitylte): avoid data race
Browse files Browse the repository at this point in the history
This diff backports 297360d.

Closes ooni/probe#2434
  • Loading branch information
bassosimone committed Mar 16, 2023
1 parent 691e539 commit 50054f5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion internal/experiment/webconnectivitylte/iox.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,10 @@ func StreamAllContext(ctx context.Context, reader io.Reader) ([]byte, error) {
defer cancel()

go func() {
buffer := make([]byte, 1<<13)
for {
// Implementation note: the buffer MUST be created at each
// loop, otherwise we're data-racing with the reader.
buffer := make([]byte, 1<<13)
count, err := reader.Read(buffer)
if count > 0 {
data := buffer[:count]
Expand Down
2 changes: 1 addition & 1 deletion internal/experiment/webconnectivitylte/measurer.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func (m *Measurer) ExperimentName() string {

// ExperimentVersion implements model.ExperimentMeasurer.
func (m *Measurer) ExperimentVersion() string {
return "0.5.22"
return "0.5.23"
}

// Run implements model.ExperimentMeasurer.
Expand Down

0 comments on commit 50054f5

Please sign in to comment.