From cc0972d31ae4bcd640a565b6a0b517fe85b132ed Mon Sep 17 00:00:00 2001 From: AnkushinDaniil Date: Wed, 8 Jan 2025 20:23:43 +0900 Subject: [PATCH] Fix data race --- rpc/handlers.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/rpc/handlers.go b/rpc/handlers.go index 56a6dbd2f..073a06806 100644 --- a/rpc/handlers.go +++ b/rpc/handlers.go @@ -7,6 +7,7 @@ import ( "encoding/json" "fmt" "log" + "maps" "math" "strings" stdsync "sync" @@ -194,9 +195,15 @@ func (h *Handler) Run(ctx context.Context) error { feed.Tee(l1HeadsSub, h.l1Heads) <-ctx.Done() - for _, sub := range h.subscriptions { + + h.mu.Lock() + subscriptions := maps.Values(h.subscriptions) + h.mu.Unlock() + + for sub := range subscriptions { sub.wg.Wait() } + return nil }