Do not log net.errClosing error when StreamWatcher is stopping.

pull/6/head
Alexandr Lurye 2015-04-04 01:39:43 +02:00 committed by Alexander Lourier
parent dbd7b186a0
commit 952ff24f0b
1 changed files with 11 additions and 0 deletions

View File

@ -76,6 +76,13 @@ func (sw *StreamWatcher) Stop() {
}
}
// stopping returns true if Stop() was called previously.
func (sw *StreamWatcher) stopping() bool {
sw.Lock()
defer sw.Unlock()
return sw.stopped
}
// receive reads result from the decoder in a loop and sends down the result channel.
func (sw *StreamWatcher) receive() {
defer close(sw.result)
@ -84,6 +91,10 @@ func (sw *StreamWatcher) receive() {
for {
action, obj, err := sw.source.Decode()
if err != nil {
// Ignore expected error.
if sw.stopping() {
return
}
switch err {
case io.EOF:
// watch closed normally