protocol/rtcp: fixed bug regarding checking of close err channel from client in routines.

This commit is contained in:
Saxon 2019-05-21 17:07:28 +09:30
parent d29141cf05
commit fbcd163864
2 changed files with 5 additions and 5 deletions

View File

@ -132,8 +132,8 @@ func (c *Client) Stop() {
c.log(logger.Debug, pkg+"Client is stopping") c.log(logger.Debug, pkg+"Client is stopping")
close(c.quit) close(c.quit)
c.conn.Close() c.conn.Close()
close(c.err)
c.wg.Wait() c.wg.Wait()
close(c.err)
} }
// Err provides read access to the Client err channel. This must be checked // Err provides read access to the Client err channel. This must be checked

View File

@ -166,14 +166,14 @@ func TestReceiveAndSend(t *testing.T) {
go func() { go func() {
for { for {
select { err, ok := <-c.Err()
case err := <-c.Err(): if ok {
const errConnClosed = "use of closed network connection" const errConnClosed = "use of closed network connection"
if !strings.Contains(err.Error(), errConnClosed) { if !strings.Contains(err.Error(), errConnClosed) {
t.Fatalf("error received from client error chan: %v\n", err) t.Fatalf("error received from client error chan: %v\n", err)
} }
} else {
default: return
} }
} }
}() }()