Skip to content

Commit

Permalink
Merge pull request #32 from mreiferson/panic_32
Browse files Browse the repository at this point in the history
panic when num conns == 0
  • Loading branch information
jehiah committed May 5, 2014
2 parents 1bebffb + e9e7d91 commit 8d9a71e
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -653,9 +653,16 @@ func (q *Reader) rdyLoop() {
case <-backoffTimerChan:
var choice *Conn

backoffTimer = nil
backoffTimerChan = nil
atomic.StoreInt64(&q.backoffDuration, 0)

q.RLock()
// pick a random connection to test the waters
var i int
if len(q.connections) == 0 {
continue
}
idx := rand.Intn(len(q.connections))
for _, c := range q.connections {
if i == idx {
Expand All @@ -666,15 +673,9 @@ func (q *Reader) rdyLoop() {
}
q.RUnlock()

if choice != nil {
log.Printf("[%s] backoff time expired, continuing with RDY 1...", choice)
// while in backoff only ever let 1 message at a time through
q.updateRDY(choice, 1)
}

backoffTimer = nil
backoffTimerChan = nil
atomic.StoreInt64(&q.backoffDuration, 0)
log.Printf("[%s] backoff time expired, continuing with RDY 1...", choice)
// while in backoff only ever let 1 message at a time through
q.updateRDY(choice, 1)
case c := <-q.rdyChan:
if backoffTimer != nil || backoffCounter > 0 {
continue
Expand Down

0 comments on commit 8d9a71e

Please sign in to comment.