Ticket #20467: 0007-fixup-Ignore-node-classes-with-zero-members-rather-t.patch

File 0007-fixup-Ignore-node-classes-with-zero-members-rather-t.patch, 1.2 KB (added by teor, 3 years ago)

Turns out that division by zero can happen in another location as well

  • NetworkScanners/BwAuthority/aggregate.py

    From 2b4ac46fc18cde173dd187573d1dbc94c56ef9c1 Mon Sep 17 00:00:00 2001
    From: teor <teor2345@gmail.com>
    Date: Thu, 10 Nov 2016 12:18:27 +1100
    Subject: [PATCH 7/7] fixup! Ignore node classes with zero members, rather than
     asserting
    
    Signed-off-by: teor <teor2345@gmail.com>
    ---
     NetworkScanners/BwAuthority/aggregate.py | 5 ++++-
     1 file changed, 4 insertions(+), 1 deletion(-)
    
    diff --git a/NetworkScanners/BwAuthority/aggregate.py b/NetworkScanners/BwAuthority/aggregate.py
    index cae436b..0f1e6bc 100755
    a b def main(argv): 
    506506      while prev_pid_avg > pid_tgt_avg[cl]:
    507507        f_nodes = filter(lambda n: n.desc_bw >= pid_tgt_avg[cl], c_nodes)
    508508        prev_pid_avg = pid_tgt_avg[cl]
    509         pid_tgt_avg[cl] = sum(map(lambda n: n.filt_bw, f_nodes))/float(len(f_nodes))
     509        if len(f_nodes) > 0:
     510          pid_tgt_avg[cl] = sum(map(lambda n: n.filt_bw, f_nodes))/float(len(f_nodes))
     511        else:
     512          pid_tgt_avg[cl] = 0.0
    510513
    511514      plog("INFO", "Network true_filt_avg["+cl+"]: "+str(true_filt_avg[cl]))
    512515      plog("INFO", "Network pid_tgt_avg["+cl+"]: "+str(pid_tgt_avg[cl]))