mirror of
https://github.com/ergochat/ergo.git
synced 2024-11-22 20:09:41 +01:00
socket: Fixup sending code so we can support more connections
This commit is contained in:
parent
f29a5f0e70
commit
c3be2d0d46
@ -50,7 +50,12 @@ func NewSocket(conn net.Conn, maxSendQBytes uint64) Socket {
|
|||||||
// Close stops a Socket from being able to send/receive any more data.
|
// Close stops a Socket from being able to send/receive any more data.
|
||||||
func (socket *Socket) Close() {
|
func (socket *Socket) Close() {
|
||||||
socket.Closed = true
|
socket.Closed = true
|
||||||
// socket will close once all data has been sent
|
|
||||||
|
// 'send data' to force close loop to happen
|
||||||
|
socket.linesToSendMutex.Lock()
|
||||||
|
socket.linesToSend = append(socket.linesToSend, "")
|
||||||
|
socket.linesToSendMutex.Unlock()
|
||||||
|
go socket.fillLineToSendExists()
|
||||||
}
|
}
|
||||||
|
|
||||||
// CertFP returns the fingerprint of the certificate provided by the client.
|
// CertFP returns the fingerprint of the certificate provided by the client.
|
||||||
@ -155,12 +160,21 @@ func (socket *Socket) RunSocketWriter() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// write data
|
// write data
|
||||||
_, err := socket.conn.Write([]byte(data))
|
if 0 < len(data) {
|
||||||
if err != nil {
|
_, err := socket.conn.Write([]byte(data))
|
||||||
errOut = true
|
if err != nil {
|
||||||
fmt.Println(err.Error())
|
errOut = true
|
||||||
|
fmt.Println(err.Error())
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// check if we're closed
|
||||||
|
if socket.Closed {
|
||||||
|
socket.linesToSendMutex.Unlock()
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
socket.linesToSendMutex.Unlock()
|
socket.linesToSendMutex.Unlock()
|
||||||
}
|
}
|
||||||
if errOut {
|
if errOut {
|
||||||
|
Loading…
Reference in New Issue
Block a user