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
}
// 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,16 +179,15 @@ func (socket *Socket) RunSocketWriter() {
break
}
}
// check if we're closed
if socket.Closed {
}
if errOut || socket.Closed {
// error out or we've been closed
break
}
}
if errOut {
// error out, bad stuff happened
break
}
// empty the lineToSendExists channel
for 0 < len(socket.lineToSendExists) {
<-socket.lineToSendExists
}
//TODO(dan): empty socket.lineToSendExists queue
socket.conn.Close()