From 20f59362ffc99b3556320eb969be3b3c5e855160 Mon Sep 17 00:00:00 2001 From: Mark Veidemanis Date: Fri, 12 Aug 2022 22:31:12 +0100 Subject: [PATCH] Subtract allocated channel slots from total --- modules/chankeep.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/modules/chankeep.py b/modules/chankeep.py index 6865f28..f91bfcb 100644 --- a/modules/chankeep.py +++ b/modules/chankeep.py @@ -60,6 +60,14 @@ def getChanFree(net, new): return False return (chanfree, chanlimits.pop()) +def getTotalChans(net): + total = 0 + for i in getActiveRelays(net): + name = net + str(i) + if name in main.IRCPool.keys(): + total += len(main.IRCPool[name].channels) + return total + def emptyChanAllocate(net, flist, new): chanfree = getChanFree(net, new) @@ -161,7 +169,11 @@ def keepChannels(net, listinfo, mean, sigrelay, relay, chanlimit): error("Network %s is too big to cover: %i relays required" % (net, sigrelay)) return num_instances = len(getActiveRelays(net)) - max_chans = chanlimit * num_instances + debug(f"keepChannels() {net} instances:{num_instances} chanlimit:{chanlimit}") + chan_slots_used = getTotalChans(net) + debug(f"keepChannels() slots_used:{chan_slots_used}") + max_chans = (chanlimit * num_instances) - chan_slots_used + debug(f"keepChannels() max_chans:{max_chans}") if coverAll: needed = relay - len(getActiveRelays(net)) debug(f"keepChannels() coverAll asking to provision {needed} relays for {net} relay:{relay}")