Fix panic when a streaming connection is closed (in multi-streams)
authorMikael Berthe <mikael@lilotux.net>
Mon, 08 May 2017 20:31:29 +0200
changeset 103 7a4604bb12d9
parent 102 84ad56b643c8
child 104 ce2b92d6d72c
Fix panic when a streaming connection is closed (in multi-streams) tagDone channels were not initialized for multiple tags streams.
cmd/stream.go
--- a/cmd/stream.go	Mon May 08 12:17:59 2017 +0200
+++ b/cmd/stream.go	Mon May 08 20:31:29 2017 +0200
@@ -115,6 +115,7 @@
 				errPrint("Launching listener for tag '%s'", t)
 			}
 			tagEvCh[i] = make(chan madon.StreamEvent)
+			tagDoneCh[i] = make(chan bool)
 			e := gClient.StreamListener(streamName, t, tagEvCh[i], stop, tagDoneCh[i])
 			if e != nil {
 				if i > 0 { // Close previous connections
@@ -157,8 +158,8 @@
 LISTEN:
 	for {
 		select {
-		case _, ok := <-done:
-			if !ok { // done is closed, end of streaming
+		case v, ok := <-done:
+			if !ok || v == true { // done is closed, end of streaming
 				break LISTEN
 			}
 		case ev := <-evChan: