Skip to content

Commit

Permalink
move backoffMtx to cover update to backoffDuration
Browse files Browse the repository at this point in the history
  • Loading branch information
jehiah committed Mar 25, 2015
1 parent 4ffbc37 commit f0be171
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions consumer.go
Original file line number Diff line number Diff line change
Expand Up @@ -656,12 +656,13 @@ func (r *Consumer) startStopContinueBackoff(conn *Conn, signal backoffSignal) {
// prevent many async failures/successes from immediately resulting in
// max backoff/normal rate (by ensuring that we dont continually incr/decr
// the counter during a backoff period)
r.backoffMtx.Lock()
if r.inBackoffBlock() {
r.backoffMtx.Unlock()
return
}

// update backoff state
r.backoffMtx.Lock()
backoffUpdated := false
switch signal {
case resumeFlag:
Expand All @@ -677,7 +678,6 @@ func (r *Consumer) startStopContinueBackoff(conn *Conn, signal backoffSignal) {
backoffUpdated = true
}
}
r.backoffMtx.Unlock()

if r.backoffCounter == 0 && backoffUpdated {
// exit backoff
Expand All @@ -700,6 +700,7 @@ func (r *Consumer) startStopContinueBackoff(conn *Conn, signal backoffSignal) {
r.updateRDY(c, 0)
}
}
r.backoffMtx.Unlock()
}

func (r *Consumer) backoff() {
Expand Down

0 comments on commit f0be171

Please sign in to comment.