Fix - wait for waitgroup to sync before reconnecting again ensuring that it just doesn't keep on creating new goroutines

This commit is contained in:
Dainis 2015-07-14 09:35:22 +03:00
parent f169aaad6f
commit f69e2d3444

3
irc.go

@ -317,6 +317,9 @@ func (irc *Connection) Disconnect() {
// Reconnect to a server using the current connection.
func (irc *Connection) Reconnect() error {
close(irc.end)
irc.Wait() //make sure that wait group is cleared ensuring that all spawned goroutines have completed
irc.end = make(chan struct{})
return irc.Connect(irc.Server)
}