Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix concurrent map read write #73

Merged
merged 1 commit into from Sep 16, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 5 additions & 2 deletions client.go
Expand Up @@ -442,12 +442,15 @@ func (c *Client) Close(disconnect *Disconnect) error {
disconnect = c.disconnect
}

channels := c.channels
channels := make(map[string]ChannelContext, len(c.channels))
for channel, channelContext := range c.channels {
channels[channel] = channelContext
}
c.mu.Unlock()

if len(channels) > 0 {
// Unsubscribe from all channels.
for channel := range c.channels {
for channel := range channels {
err := c.unsubscribe(channel)
if err != nil {
c.node.logger.log(newLogEntry(LogLevelError, "error unsubscribing client from channel", map[string]interface{}{"channel": channel, "user": c.user, "client": c.uid, "error": err.Error()}))
Expand Down