Browse Source

Merge pull request #733 from ChannelMeter/fix/timer-reset-race

Fix Racy call to Reset in feederLoop
Evan Huus 9 years ago
parent
commit
1639c3e2fd
1 changed files with 2 additions and 1 deletions
  1. 2 1
      consumer.go

+ 2 - 1
consumer.go

@@ -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: