From a74450d6caede853a26df8c632107a29d2b521e2 Mon Sep 17 00:00:00 2001 From: Shivaram Lingamneni Date: Mon, 2 Mar 2020 01:22:00 -0500 Subject: [PATCH] remove redundant database write on always-on recreation --- irc/channel.go | 2 +- irc/client.go | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/irc/channel.go b/irc/channel.go index 3b241435..ba8658bd 100644 --- a/irc/channel.go +++ b/irc/channel.go @@ -720,7 +720,7 @@ func (channel *Channel) Join(client *Client, key string, isSajoin bool, rb *Resp channel.AddHistoryItem(histItem) } - client.addChannel(channel) + client.addChannel(channel, rb == nil) if rb == nil { return diff --git a/irc/client.go b/irc/client.go index 9e1e3ff3..6841791f 100644 --- a/irc/client.go +++ b/irc/client.go @@ -1496,13 +1496,15 @@ func (session *Session) Notice(text string) { session.Send(nil, session.client.server.name, "NOTICE", session.client.Nick(), text) } -func (client *Client) addChannel(channel *Channel) { +// `simulated` is for the fake join of an always-on client +// (we just read the channel name from the database, there's no need to write it back) +func (client *Client) addChannel(channel *Channel, simulated bool) { client.stateMutex.Lock() client.channels[channel] = true alwaysOn := client.alwaysOn client.stateMutex.Unlock() - if alwaysOn { + if alwaysOn && !simulated { client.markDirty(IncludeChannels) } }