From 3b5fa9fe31d59e106eb24d3e3f0a63d702574731 Mon Sep 17 00:00:00 2001 From: Dainis Tillers Date: Fri, 28 Aug 2015 21:01:23 +0300 Subject: [PATCH] Fix - #65, when disconnect is called it will try to reconnect again in the Loop function, but Disconnect has already closed the channel --- irc.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/irc.go b/irc.go index 576a9b0..2218a39 100644 --- a/irc.go +++ b/irc.go @@ -345,6 +345,9 @@ func (irc *Connection) Disconnect() { if irc.end != nil { close(irc.end) } + + irc.end = nil + if irc.pwrite != nil { close(irc.pwrite) } @@ -359,7 +362,12 @@ func (irc *Connection) Disconnect() { // Reconnect to a server using the current connection. func (irc *Connection) Reconnect() error { - close(irc.end) + if irc.end != nil { + close(irc.end) + } + + irc.end = nil + irc.Wait() //make sure that wait group is cleared ensuring that all spawned goroutines have completed irc.end = make(chan struct{})