mirror of
https://github.com/ergochat/ergo.git
synced 2024-11-29 15:40:02 +01:00
attempt to fix hang condition in quit sequence
This commit is contained in:
parent
a9eae872c9
commit
d35fe6088c
@ -78,7 +78,7 @@ func (client *Client) ConnectionTimeout() {
|
|||||||
message: "connection timeout",
|
message: "connection timeout",
|
||||||
}
|
}
|
||||||
msg.SetClient(client)
|
msg.SetClient(client)
|
||||||
client.server.commands <- msg
|
client.server.Command(msg)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (client *Client) ConnectionClosed() {
|
func (client *Client) ConnectionClosed() {
|
||||||
@ -86,7 +86,7 @@ func (client *Client) ConnectionClosed() {
|
|||||||
message: "connection closed",
|
message: "connection closed",
|
||||||
}
|
}
|
||||||
msg.SetClient(client)
|
msg.SetClient(client)
|
||||||
client.server.commands <- msg
|
client.server.Command(msg)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Client) readCommands() {
|
func (c *Client) readCommands() {
|
||||||
@ -106,7 +106,7 @@ func (c *Client) readCommands() {
|
|||||||
if DEBUG_CLIENT {
|
if DEBUG_CLIENT {
|
||||||
log.Printf("%s sending %s", c, m)
|
log.Printf("%s sending %s", c, m)
|
||||||
}
|
}
|
||||||
c.server.commands <- m
|
c.server.Command(m)
|
||||||
if DEBUG_CLIENT {
|
if DEBUG_CLIENT {
|
||||||
log.Printf("%s sent %s", c, m)
|
log.Printf("%s sent %s", c, m)
|
||||||
}
|
}
|
||||||
@ -124,6 +124,8 @@ func (client *Client) writeReplies() {
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
close(client.replies)
|
||||||
|
client.replies = nil
|
||||||
client.ConnectionClosed()
|
client.ConnectionClosed()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -138,10 +140,9 @@ func (client *Client) Destroy() {
|
|||||||
|
|
||||||
client.destroyed = true
|
client.destroyed = true
|
||||||
|
|
||||||
client.socket.Close()
|
|
||||||
|
|
||||||
close(client.replies)
|
close(client.replies)
|
||||||
client.replies = nil
|
|
||||||
|
client.socket.Close()
|
||||||
|
|
||||||
if client.idleTimer != nil {
|
if client.idleTimer != nil {
|
||||||
client.idleTimer.Stop()
|
client.idleTimer.Stop()
|
||||||
@ -160,11 +161,11 @@ func (client *Client) Destroy() {
|
|||||||
|
|
||||||
func (client *Client) Reply(replies ...Reply) {
|
func (client *Client) Reply(replies ...Reply) {
|
||||||
for _, reply := range replies {
|
for _, reply := range replies {
|
||||||
if client.destroyed {
|
if client.replies == nil {
|
||||||
if DEBUG_CLIENT {
|
if DEBUG_CLIENT {
|
||||||
log.Printf("%s.Reply: destroyed: %s", client, reply)
|
log.Printf("%s.Reply: dropped: %s", client, reply)
|
||||||
}
|
}
|
||||||
break
|
continue
|
||||||
}
|
}
|
||||||
client.replies <- reply
|
client.replies <- reply
|
||||||
}
|
}
|
||||||
|
@ -304,7 +304,6 @@ func (m *QuitCommand) HandleServer(server *Server) {
|
|||||||
iclients := client.InterestedClients()
|
iclients := client.InterestedClients()
|
||||||
iclients.Remove(client)
|
iclients.Remove(client)
|
||||||
|
|
||||||
server.clients.Remove(client)
|
|
||||||
for channel := range client.channels {
|
for channel := range client.channels {
|
||||||
channel.members.Remove(client)
|
channel.members.Remove(client)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user