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:
parent
f169aaad6f
commit
f69e2d3444
3
irc.go
3
irc.go
@ -317,6 +317,9 @@ func (irc *Connection) Disconnect() {
|
|||||||
|
|
||||||
// Reconnect to a server using the current connection.
|
// Reconnect to a server using the current connection.
|
||||||
func (irc *Connection) Reconnect() error {
|
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{})
|
irc.end = make(chan struct{})
|
||||||
return irc.Connect(irc.Server)
|
return irc.Connect(irc.Server)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user