Skip to content
This repository has been archived by the owner on Apr 19, 2024. It is now read-only.

Commit

Permalink
Fixed race condition on peer shutdown
Browse files Browse the repository at this point in the history
  • Loading branch information
thrawn01 committed Dec 18, 2020
1 parent 9143dd3 commit f3cccc2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 5 additions & 2 deletions peer_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -239,13 +239,16 @@ func (c *PeerClient) getPeerRateLimitsBatch(ctx context.Context, r *RateLimitReq
return nil, err
}

// See NOTE above about RLock and wg.Add(1)
c.mutex.RLock()
if c.status == peerClosing {
return nil, &PeerErr{err: errors.New("already disconnecting")}
}
req := request{request: r, resp: make(chan *response, 1)}

// Enqueue the request to be sent
c.queue <- &req

// See NOTE above about RLock and wg.Add(1)
c.mutex.RLock()
c.wg.Add(1)
defer func() {
c.mutex.RUnlock()
Expand Down
2 changes: 1 addition & 1 deletion version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.0.0-rc.3
1.0.0-rc.4

0 comments on commit f3cccc2

Please sign in to comment.