From fbcd1638643d52e14dde984a9a4aeef234c4e718 Mon Sep 17 00:00:00 2001 From: Saxon Date: Tue, 21 May 2019 17:07:28 +0930 Subject: [PATCH] protocol/rtcp: fixed bug regarding checking of close err channel from client in routines. --- protocol/rtcp/client.go | 2 +- protocol/rtcp/client_test.go | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) 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 } } }()