3
0
mirror of https://github.com/ergochat/ergo.git synced 2024-12-23 03:02:48 +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() { func (client *Client) ConnectionClosed() {
if client.destroyed {
return
}
msg := &QuitCommand{ msg := &QuitCommand{
message: "connection closed", message: "connection closed",
} }
@ -121,10 +125,9 @@ func (client *Client) writeReplies() {
} }
if err := client.socket.Write(reply.Format(client)); err != nil { if err := client.socket.Write(reply.Format(client)); err != nil {
break
}
}
close(client.replies) close(client.replies)
}
}
client.replies = nil client.replies = nil
client.ConnectionClosed() client.ConnectionClosed()
} }
@ -140,7 +143,9 @@ func (client *Client) Destroy() {
client.destroyed = true client.destroyed = true
if client.replies != nil {
close(client.replies) close(client.replies)
}
client.socket.Close() client.socket.Close()