From 86957d439269226f283c6286022134951e2e4d25 Mon Sep 17 00:00:00 2001 From: Daniel Oaks Date: Mon, 17 Apr 2017 22:35:25 +1000 Subject: [PATCH] socket: Fix quitting --- irc/socket.go | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/irc/socket.go b/irc/socket.go index fc83ef84..fbb748be 100644 --- a/irc/socket.go +++ b/irc/socket.go @@ -140,6 +140,12 @@ func (socket *Socket) RunSocketWriter() { break } + // check number of lines to send + if len(socket.linesToSend) < 1 { + fmt.Println("No line to send found on socket writer") + continue + } + // check sendq var sendQBytes uint64 for _, line := range socket.linesToSend { @@ -173,17 +179,16 @@ func (socket *Socket) RunSocketWriter() { break } } - - // check if we're closed - if socket.Closed { - break - } } - if errOut { - // error out, bad stuff happened + if errOut || socket.Closed { + // error out or we've been closed break } } + // empty the lineToSendExists channel + for 0 < len(socket.lineToSendExists) { + <-socket.lineToSendExists + } //TODO(dan): empty socket.lineToSendExists queue socket.conn.Close() if !socket.Closed {