Fix - #65, when disconnect is called it will try to reconnect again in the Loop function, but Disconnect has already closed the channel

This commit is contained in:
Dainis Tillers 2015-08-28 21:01:23 +03:00
parent 172717c0c5
commit 3b5fa9fe31

10
irc.go
View File

@ -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{})