ionorg / ion-sdk-go

ion sdk for golang

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

panic: close of closed channel

manishiitg opened this issue · comments

Your environment.

  • Version: master
  • Browser: include version
  • Other Information - stacktraces, related issues, suggestions how to fix, links for us to have context

What did you do?

https://github.com/pion/ion-sdk-go/blob/master/client.go#L241

if c.Close() is called before publish, it gives a panic

What did you expect?

What happened?

i think the issue is that when we do Close(), it interally calls delete and which again calls Close so it panics always

https://github.com/pion/ion-sdk-go/blob/master/client.go#L270

https://github.com/pion/ion-sdk-go/blob/1e8126477a4c28444a8b873d63aa6faf37078108/engine.go#L58

also client Close should internally Stop the webm producer as well, if its being used

I suffer from the same issue.

Client.Close() calls Engine.DelClient() which calls Client.Close() again. This makes panic since it tries to close the closed channel, c.notify here.

Is there any reason that Engine.DelClient() does c.Close() again?

// DelClient delete a client
func (e *Engine) DelClient(c *Client) error {
	e.Lock()
	if e.clients[c.sid] == nil {
		e.Unlock()
		return errInvalidSessID
	}
/*
	if c, ok := e.clients[c.sid][c.uid]; ok && (c != nil) {
		c.Close()
	}
*/
	delete(e.clients[c.sid], c.uid)
	e.Unlock()
	return nil
}