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

remove redundant database write on always-on recreation

This commit is contained in:
Shivaram Lingamneni 2020-03-02 01:22:00 -05:00
parent b4f720ae04
commit a74450d6ca
2 changed files with 5 additions and 3 deletions

View File

@ -720,7 +720,7 @@ func (channel *Channel) Join(client *Client, key string, isSajoin bool, rb *Resp
channel.AddHistoryItem(histItem) channel.AddHistoryItem(histItem)
} }
client.addChannel(channel) client.addChannel(channel, rb == nil)
if rb == nil { if rb == nil {
return return

View File

@ -1496,13 +1496,15 @@ func (session *Session) Notice(text string) {
session.Send(nil, session.client.server.name, "NOTICE", session.client.Nick(), text) 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.stateMutex.Lock()
client.channels[channel] = true client.channels[channel] = true
alwaysOn := client.alwaysOn alwaysOn := client.alwaysOn
client.stateMutex.Unlock() client.stateMutex.Unlock()
if alwaysOn { if alwaysOn && !simulated {
client.markDirty(IncludeChannels) client.markDirty(IncludeChannels)
} }
} }