Explorar el Código

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

Fix Racy call to Reset in feederLoop
Evan Huus hace 9 años
padre
commit
1639c3e2fd
Se han modificado 1 ficheros con 2 adiciones y 1 borrados
  1. 2 1
      consumer.go

+ 2 - 1
consumer.go

@@ -420,10 +420,11 @@ feederLoop:
 		msgs, child.responseResult = child.parseResponse(response)
 		msgs, child.responseResult = child.parseResponse(response)
 
 
 		for i, msg := range msgs {
 		for i, msg := range msgs {
-			if !expiryTimer.Reset(child.conf.Consumer.MaxProcessingTime) {
+			if !expiryTimer.Stop() {
 				// expiryTimer was expired; clear out the waiting msg
 				// expiryTimer was expired; clear out the waiting msg
 				<-expiryTimer.C
 				<-expiryTimer.C
 			}
 			}
+			expiryTimer.Reset(child.conf.Consumer.MaxProcessingTime)
 
 
 			select {
 			select {
 			case child.messages <- msg:
 			case child.messages <- msg: