From bfeba1f2f30daf22c3405d4147b09f255b5dc39b Mon Sep 17 00:00:00 2001 From: Shivaram Lingamneni Date: Fri, 12 Jun 2020 17:13:47 -0400 Subject: [PATCH] remove client join time tracking --- irc/channel.go | 21 +++++---------------- irc/handlers.go | 8 +------- 2 files changed, 6 insertions(+), 23 deletions(-) diff --git a/irc/channel.go b/irc/channel.go index 3b47b49d..842ddc39 100644 --- a/irc/channel.go +++ b/irc/channel.go @@ -30,7 +30,6 @@ type Channel struct { key string members MemberSet membersCache []*Client // allow iteration over channel members without holding the lock - memberJoinTimes map[*Client]time.Time name string nameCasefolded string server *Server @@ -58,12 +57,11 @@ func NewChannel(s *Server, name, casefoldedName string, registered bool) *Channe config := s.Config() channel := &Channel{ - createdTime: time.Now().UTC(), // may be overwritten by applyRegInfo - members: make(MemberSet), - memberJoinTimes: make(map[*Client]time.Time), - name: name, - nameCasefolded: casefoldedName, - server: s, + createdTime: time.Now().UTC(), // may be overwritten by applyRegInfo + members: make(MemberSet), + name: name, + nameCasefolded: casefoldedName, + server: s, } channel.initializeLists() @@ -553,13 +551,6 @@ func (channel *Channel) ClientModeStrings(client *Client) (result []string) { return } -func (channel *Channel) ClientJoinTime(client *Client) time.Time { - channel.stateMutex.RLock() - defer channel.stateMutex.RUnlock() - time := channel.memberJoinTimes[client] - return time -} - func (channel *Channel) ClientHasPrivsOver(client *Client, target *Client) bool { channel.stateMutex.RLock() founder := channel.registeredFounder @@ -736,7 +727,6 @@ func (channel *Channel) Join(client *Client, key string, isSajoin bool, rb *Resp defer channel.stateMutex.Unlock() channel.members.Add(client) - channel.memberJoinTimes[client] = time.Now().UTC() firstJoin := len(channel.members) == 1 newChannel := firstJoin && channel.registeredFounder == "" if newChannel { @@ -1375,7 +1365,6 @@ func (channel *Channel) Quit(client *Client) { channel.stateMutex.Lock() channel.members.Remove(client) - delete(channel.memberJoinTimes, client) channelEmpty := len(channel.members) == 0 channel.stateMutex.Unlock() channel.regenerateMembersCache() diff --git a/irc/handlers.go b/irc/handlers.go index 3daeb358..c0decf2d 100644 --- a/irc/handlers.go +++ b/irc/handlers.go @@ -939,13 +939,7 @@ func extjwtHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *Re claims["joined"] = 0 claims["cmodes"] = []string{} if channel.hasClient(client) { - joinTime := channel.ClientJoinTime(client) - if joinTime.IsZero() { - // shouldn't happen, only in races - rb.Add(nil, server.name, "FAIL", "EXTJWT", "UNKNOWN_ERROR", client.t("Channel join time is inconsistent, JWT not generated")) - return false - } - claims["joined"] = joinTime.Unix() + claims["joined"] = 1 claims["cmodes"] = channel.ClientModeStrings(client) } }