Skip to content

Commit

Permalink
Merge pull request #733 from ChannelMeter/fix/timer-reset-race
Browse files Browse the repository at this point in the history
Fix Racy call to Reset in feederLoop
  • Loading branch information
eapache authored Aug 23, 2016
2 parents 4f47ee4 + 779ef6a commit 1639c3e
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion consumer.go
Original file line number Diff line number Diff line change
Expand Up @@ -420,10 +420,11 @@ feederLoop:
msgs, child.responseResult = child.parseResponse(response)

for i, msg := range msgs {
if !expiryTimer.Reset(child.conf.Consumer.MaxProcessingTime) {
if !expiryTimer.Stop() {
// expiryTimer was expired; clear out the waiting msg
<-expiryTimer.C
}
expiryTimer.Reset(child.conf.Consumer.MaxProcessingTime)

select {
case child.messages <- msg:
Expand Down

0 comments on commit 1639c3e

Please sign in to comment.