Changeset 738 in code for trunk/upstream.go


Ignore:
Timestamp:
Dec 2, 2021, 6:29:44 PM (4 years ago)
Author:
contact
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/upstream.go

    r737 r738  
    386386}
    387387
     388func (uc *upstreamConn) cancelPendingCommandsByDownstreamID(downstreamID uint64) {
     389        for cmd := range uc.pendingCmds {
     390                // We can't cancel the currently running command stored in
     391                // uc.pendingCmds[cmd][0]
     392                for i := len(uc.pendingCmds[cmd]) - 1; i >= 1; i-- {
     393                        if uc.pendingCmds[cmd][i].downstreamID == downstreamID {
     394                                uc.pendingCmds[cmd] = append(uc.pendingCmds[cmd][:i], uc.pendingCmds[cmd][i+1:]...)
     395                        }
     396                }
     397        }
     398}
     399
    388400func (uc *upstreamConn) parseMembershipPrefix(s string) (ms *memberships, nick string) {
    389401        memberships := make(memberships, 0, 4)
Note: See TracChangeset for help on using the changeset viewer.