Permalink
Browse files

Close stop channel if it is still available

  • Loading branch information...
1 parent dfd1a47 commit bb91f415b946cc73718800562b5623f50b52ae26 @pietern pietern committed Jun 4, 2012
Showing with 12 additions and 2 deletions.
  1. +7 −0 client.go
  2. +5 −2 connection.go
View
7 client.go
@@ -382,6 +382,13 @@ func (t *Client) Run(d Dialer, h Handshaker) error {
}
}
+ // Close stop channel if it is still available
+ select {
+ case sc = <-t.scc:
+ close(sc)
+ default:
+ }
+
return nil
}
View
7 connection.go
@@ -287,8 +287,11 @@ func (c *Connection) Run() error {
// Close connection
c.rw.Close()
- // Drain readObject channel to make read goroutine quit
- for _ = range rc {
+ // Close stop channel if it is still available
+ select {
+ case sc = <-c.scc:
+ close(sc)
+ default:
}
// Can't receive more PONGs

0 comments on commit bb91f41

Please sign in to comment.