diff --git a/cmd/zetaclientd/start.go b/cmd/zetaclientd/start.go index 46d204fa34..b9722c9213 100644 --- a/cmd/zetaclientd/start.go +++ b/cmd/zetaclientd/start.go @@ -231,6 +231,7 @@ func Start(_ *cobra.Command, _ []string) error { go func() { host := tssServer.GetP2PHost() pingRTT := make(map[peer.ID]int64) + pingRTTLock := sync.Mutex{} for { var wg sync.WaitGroup for _, p := range whitelistedPeers { @@ -240,6 +241,8 @@ func Start(_ *cobra.Command, _ []string) error { ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second) defer cancel() result := <-ping.Ping(ctx, host, p) + pingRTTLock.Lock() + defer pingRTTLock.Unlock() if result.Error != nil { masterLogger.Error().Err(result.Error).Msg("ping error") pingRTT[p] = -1 // RTT -1 indicate ping error