From 55274d7213e2017f23a0e38b96c1ca7ff5c1c1de Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Mon, 29 Mar 2021 16:58:56 +0200 Subject: [PATCH] Move network.clients to user No need to have this list per-network. --- upstream.go | 2 +- user.go | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/upstream.go b/upstream.go index 422b82d..409ab0b 100644 --- a/upstream.go +++ b/upstream.go @@ -1755,7 +1755,7 @@ func (uc *upstreamConn) appendLog(entity string, msg *irc.Message) (msgID string delivered = make(deliveredClientMap) uc.network.delivered.SetValue(entity, delivered) - for clientName, _ := range uc.network.clients { + for clientName, _ := range uc.user.clients { delivered[clientName] = lastID } } diff --git a/user.go b/user.go index fe5f504..4a637c5 100644 --- a/user.go +++ b/user.go @@ -65,7 +65,6 @@ type network struct { conn *upstreamConn channels channelCasemapMap delivered deliveredCasemapMap - clients map[string]struct{} // indexed by client name lastError error casemap casemapping } @@ -83,7 +82,6 @@ func newNetwork(user *user, record *Network, channels []Channel) *network { stopped: make(chan struct{}), channels: m, delivered: deliveredCasemapMap{newCasemapMap(0)}, - clients: make(map[string]struct{}), casemap: casemapRFC1459, } } @@ -275,6 +273,7 @@ type user struct { networks []*network downstreamConns []*downstreamConn msgStore messageStore + clients map[string]struct{} // indexed by client name // LIST commands in progress pendingLISTs []pendingLIST @@ -300,6 +299,7 @@ func newUser(srv *Server, record *User) *user { events: make(chan event, 64), done: make(chan struct{}), msgStore: msgStore, + clients: make(map[string]struct{}), } } @@ -446,7 +446,6 @@ func (u *user) run() { u.downstreamConns = append(u.downstreamConns, dc) dc.forEachNetwork(func(network *network) { - network.clients[dc.clientName] = struct{}{} if network.lastError != nil { sendServiceNOTICE(dc, fmt.Sprintf("disconnected from %s: %v", network.GetName(), network.lastError)) } @@ -455,6 +454,8 @@ func (u *user) run() { u.forEachUpstream(func(uc *upstreamConn) { uc.updateAway() }) + + u.clients[dc.clientName] = struct{}{} case eventDownstreamDisconnected: dc := e.dc