diff --git a/protocol/rtcp/client.go b/protocol/rtcp/client.go index 6accecb8..87194405 100644 --- a/protocol/rtcp/client.go +++ b/protocol/rtcp/client.go @@ -132,8 +132,8 @@ func (c *Client) Stop() { c.log(logger.Debug, pkg+"Client is stopping") close(c.quit) c.conn.Close() - close(c.err) c.wg.Wait() + close(c.err) } // Err provides read access to the Client err channel. This must be checked diff --git a/protocol/rtcp/client_test.go b/protocol/rtcp/client_test.go index 111bcbbf..6c95c75d 100644 --- a/protocol/rtcp/client_test.go +++ b/protocol/rtcp/client_test.go @@ -166,14 +166,14 @@ func TestReceiveAndSend(t *testing.T) { go func() { for { - select { - case err := <-c.Err(): + err, ok := <-c.Err() + if ok { const errConnClosed = "use of closed network connection" if !strings.Contains(err.Error(), errConnClosed) { t.Fatalf("error received from client error chan: %v\n", err) } - - default: + } else { + return } } }()