Skip to content

Commit

Permalink
Merge pull request #87 from vinted/receive_markpeer_fix
Browse files Browse the repository at this point in the history
receive/handler: do not double lock
  • Loading branch information
GiedriusS authored Feb 8, 2024
2 parents 0840b65 + 1b06049 commit ec88d1b
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion pkg/receive/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -1454,7 +1454,7 @@ func (p *peerGroup) getConnection(ctx context.Context, addr string) (WriteableSt
}
conn, err := p.dialer(ctx, addr, p.dialOpts...)
if err != nil {
p.markPeerUnavailable(addr)
p.markPeerUnavailableUnlocked(addr)
dialError := errors.Wrap(err, "failed to dial peer")
return nil, errors.Wrap(dialError, errUnavailable.Error())
}
Expand All @@ -1467,6 +1467,10 @@ func (p *peerGroup) markPeerUnavailable(addr string) {
p.m.Lock()
defer p.m.Unlock()

p.markPeerUnavailableUnlocked(addr)
}

func (p *peerGroup) markPeerUnavailableUnlocked(addr string) {
state, ok := p.peerStates[addr]
if !ok {
state = &retryState{attempt: -1}
Expand Down

0 comments on commit ec88d1b

Please sign in to comment.