socket: Fix quitting

This commit is contained in:
Daniel Oaks 2017-04-17 22:35:25 +10:00
parent 7aaa30d399
commit 86957d4392
1 changed files with 12 additions and 7 deletions

View File

@ -140,6 +140,12 @@ func (socket *Socket) RunSocketWriter() {
break 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 // check sendq
var sendQBytes uint64 var sendQBytes uint64
for _, line := range socket.linesToSend { for _, line := range socket.linesToSend {
@ -173,17 +179,16 @@ func (socket *Socket) RunSocketWriter() {
break break
} }
} }
// check if we're closed
if socket.Closed {
break
}
} }
if errOut { if errOut || socket.Closed {
// error out, bad stuff happened // error out or we've been closed
break break
} }
} }
// empty the lineToSendExists channel
for 0 < len(socket.lineToSendExists) {
<-socket.lineToSendExists
}
//TODO(dan): empty socket.lineToSendExists queue //TODO(dan): empty socket.lineToSendExists queue
socket.conn.Close() socket.conn.Close()
if !socket.Closed { if !socket.Closed {