Cancel pending commands on downstream disconnect
If a client queues a high number of commands and then disconnects, remove all of the pending commands. This avoids unnecessarily sending commands whose results won't be used.
This commit is contained in:
parent
1620344f0a
commit
a413681253
12
upstream.go
12
upstream.go
@ -385,6 +385,18 @@ func (uc *upstreamConn) dequeueCommand(cmd string) (*downstreamConn, *irc.Messag
|
|||||||
return dc, msg
|
return dc, msg
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (uc *upstreamConn) cancelPendingCommandsByDownstreamID(downstreamID uint64) {
|
||||||
|
for cmd := range uc.pendingCmds {
|
||||||
|
// We can't cancel the currently running command stored in
|
||||||
|
// uc.pendingCmds[cmd][0]
|
||||||
|
for i := len(uc.pendingCmds[cmd]) - 1; i >= 1; i-- {
|
||||||
|
if uc.pendingCmds[cmd][i].downstreamID == downstreamID {
|
||||||
|
uc.pendingCmds[cmd] = append(uc.pendingCmds[cmd][:i], uc.pendingCmds[cmd][i+1:]...)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (uc *upstreamConn) parseMembershipPrefix(s string) (ms *memberships, nick string) {
|
func (uc *upstreamConn) parseMembershipPrefix(s string) (ms *memberships, nick string) {
|
||||||
memberships := make(memberships, 0, 4)
|
memberships := make(memberships, 0, 4)
|
||||||
i := 0
|
i := 0
|
||||||
|
Loading…
Reference in New Issue
Block a user