check for error when stopping WSClient

This commit is contained in:
Anton Kaliaev 2017-11-06 13:23:51 -05:00
parent 69b5da766c
commit c6b2334fa3
No known key found for this signature in database
GPG Key ID: 7B6881D965918214

View File

@ -170,9 +170,11 @@ func (c *WSClient) OnStop() {}
// channel is closed.
func (c *WSClient) Stop() error {
err := c.BaseService.Stop()
// only close user-facing channels when we can't write to them
c.wg.Wait()
close(c.ResponsesCh)
if err == nil {
// only close user-facing channels when we can't write to them
c.wg.Wait()
close(c.ResponsesCh)
}
return err
}