Skip to content

Commit

Permalink
quic: fix race condition in runAsync test helper
Browse files Browse the repository at this point in the history
asyncTestState.wakeAsync runs on the conn's goroutine and
accesses as.blocked, so we need to hold as.mu while
initializing as.blocked in runAsync.

For golang/go#58547

Change-Id: Idb5921895cee89dfceec2b2439c43f2e380b64ce
Reviewed-on: https://go-review.googlesource.com/c/net/+/524095
LUCI-TryBot-Result: Go LUCI <[email protected]>
Reviewed-by: Jonathan Amsterdam <[email protected]>
  • Loading branch information
neild committed Aug 29, 2023
1 parent fe2abcb commit 8b010a5
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions internal/quic/conn_async_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,9 @@ func runAsync[T any](ts *testConn, f func(context.Context) (T, error)) *asyncOp[
as := &ts.asyncTestState
if as.notify == nil {
as.notify = make(chan struct{})
as.mu.Lock()
as.blocked = make(map[*blockedAsync]struct{})
as.mu.Unlock()
}
_, file, line, _ := runtime.Caller(1)
ctx := context.WithValue(context.Background(), asyncContextKey{}, true)
Expand Down

0 comments on commit 8b010a5

Please sign in to comment.