Skip to content

Commit 2f4a6c4

Browse files
Fix data race
1 parent 0c9ee5a commit 2f4a6c4

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

Diff for: rpc/handlers.go

+8-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"encoding/json"
88
"fmt"
99
"log"
10+
"maps"
1011
"math"
1112
"strings"
1213
stdsync "sync"
@@ -194,9 +195,15 @@ func (h *Handler) Run(ctx context.Context) error {
194195
feed.Tee(l1HeadsSub, h.l1Heads)
195196

196197
<-ctx.Done()
197-
for _, sub := range h.subscriptions {
198+
199+
h.mu.Lock()
200+
subscriptions := maps.Values(h.subscriptions)
201+
h.mu.Unlock()
202+
203+
for sub := range subscriptions {
198204
sub.wg.Wait()
199205
}
206+
200207
return nil
201208
}
202209

0 commit comments

Comments
 (0)