mirror of
https://github.com/ergochat/ergo.git
synced 2024-11-10 22:19:31 +01:00
socket: Make closing work a little better
This commit is contained in:
parent
e0035dfa04
commit
121269661b
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user