Skip to content

Commit

Permalink
fix potential data race
Browse files Browse the repository at this point in the history
  • Loading branch information
marwan-at-work committed Nov 16, 2023
1 parent 3aa359b commit ff7604c
Showing 1 changed file with 1 addition and 11 deletions.
12 changes: 1 addition & 11 deletions client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Expand Down Expand Up @@ -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)
}
}

0 comments on commit ff7604c

Please sign in to comment.