diff --git a/irc/socket.go b/irc/socket.go index 929c5389..fc83ef84 100644 --- a/irc/socket.go +++ b/irc/socket.go @@ -51,10 +51,7 @@ func NewSocket(conn net.Conn, maxSendQBytes uint64) Socket { func (socket *Socket) Close() { socket.Closed = true - // 'send data' to force close loop to happen - socket.linesToSendMutex.Lock() - socket.linesToSend = append(socket.linesToSend, "") - socket.linesToSendMutex.Unlock() + // force close loop to happen go socket.fillLineToSendExists() } @@ -138,6 +135,11 @@ func (socket *Socket) RunSocketWriter() { case <-socket.lineToSendExists: socket.linesToSendMutex.Lock() + // check if we're closed + if socket.Closed { + break + } + // check sendq var sendQBytes uint64 for _, line := range socket.linesToSend {