mirror of
https://github.com/ergochat/ergo.git
synced 2025-12-20 10:10:08 -08:00
socket: Make closing work a little better
This commit is contained in:
parent
e0035dfa04
commit
121269661b
1 changed files with 6 additions and 4 deletions
|
|
@ -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…
Add table
Add a link
Reference in a new issue