Streamer: don't signal done too early
Due to a refactoring mistake, we were closing the channel that signal
the completion of streaming too early, thus defeating the whole purpose
of the aforementioned channel.
This patch restores the intended behaviour.
@@ -219,6 +219,10 @@ type wsStreamer struct {
done chan struct{}
}
+func (ws *wsStreamer) streamDone() {
+ close(ws.done)
+}
+
func (ws *wsStreamer) Stream(options StreamOptions) error {
wsReadWriter := &BinaryReadWriter{Conn: ws.conn}
@@ -234,7 +238,7 @@ func (ws *wsStreamer) Stream(options StreamOptions) error {
copyErr <- err
}()
- close(ws.done)
+ defer ws.streamDone()
return <-copyErr
}
