3
0
mirror of https://github.com/ergochat/ergo.git synced 2024-12-22 18:52:41 +01:00

don't close replies too many times

This commit is contained in:
Jeremy Latt 2014-02-13 20:26:56 -08:00
parent d35fe6088c
commit 03b6caa597

View File

@ -82,6 +82,10 @@ func (client *Client) ConnectionTimeout() {
}
func (client *Client) ConnectionClosed() {
if client.destroyed {
return
}
msg := &QuitCommand{
message: "connection closed",
}
@ -121,10 +125,9 @@ func (client *Client) writeReplies() {
}
if err := client.socket.Write(reply.Format(client)); err != nil {
break
}
}
close(client.replies)
}
}
client.replies = nil
client.ConnectionClosed()
}
@ -140,7 +143,9 @@ func (client *Client) Destroy() {
client.destroyed = true
if client.replies != nil {
close(client.replies)
}
client.socket.Close()