3
0
mirror of https://github.com/ergochat/ergo.git synced 2024-12-23 11:12:44 +01:00

socket: Fix quitting

This commit is contained in:
Daniel Oaks 2017-04-17 22:35:25 +10:00
parent 7aaa30d399
commit 86957d4392

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