From ff7604ca2c608cc5d838a0aacf9de5a7b109848d Mon Sep 17 00:00:00 2001 From: Marwan Sulaiman Date: Wed, 15 Nov 2023 22:16:16 -0500 Subject: [PATCH] fix potential data race --- client/client.go | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/client/client.go b/client/client.go index 435ef9d..a2eccef 100644 --- a/client/client.go +++ b/client/client.go @@ -114,12 +114,12 @@ func (c *Client) readWorker(ctx context.Context) { } c.mu.Lock() ch, ok := c.rpcs[resp.GetId()] + delete(c.rpcs, resp.GetId()) c.mu.Unlock() if !ok { fmt.Fprintf(os.Stderr, "could not find call for %d: %v\n", resp.GetId(), &resp) continue } - delete(c.rpcs, resp.GetId()) ch <- &resp } } @@ -160,13 +160,3 @@ func (c *Client) Close() error { func id(i int64) *int64 { return &i } - -func str(s string) *string { - return &s -} - -func must(err error) { - if err != nil { - panic(err) - } -}