From f69e2d34447f899c9fd0984c8e3cfbb1271e0381 Mon Sep 17 00:00:00 2001 From: Dainis Date: Tue, 14 Jul 2015 09:35:22 +0300 Subject: [PATCH] Fix - wait for waitgroup to sync before reconnecting again ensuring that it just doesn't keep on creating new goroutines --- irc.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/irc.go b/irc.go index 56d7c07..7a3a3b3 100644 --- a/irc.go +++ b/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) }