[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[or-cvs] r19378: {torctl} Prevent some floating point range errors. (torctl/trunk/python/TorCtl)



Author: mikeperry
Date: 2009-04-26 01:07:20 -0400 (Sun, 26 Apr 2009)
New Revision: 19378

Modified:
   torctl/trunk/python/TorCtl/StatsSupport.py
Log:

Prevent some floating point range errors.



Modified: torctl/trunk/python/TorCtl/StatsSupport.py
===================================================================
--- torctl/trunk/python/TorCtl/StatsSupport.py	2009-04-26 03:59:35 UTC (rev 19377)
+++ torctl/trunk/python/TorCtl/StatsSupport.py	2009-04-26 05:07:20 UTC (rev 19378)
@@ -293,15 +293,19 @@
     return (1.0*(self.strm_suspected+self.strm_failed))/self.strm_chosen
 
   def circ_suspect_ratio(self):
+    if 1.0-StatsRouter.global_cs_mean <= 0.0: return 0
     return (1.0-self.circ_suspect_rate())/(1.0-StatsRouter.global_cs_mean)
 
   def strm_suspect_ratio(self):
+    if 1.0-StatsRouter.global_ss_mean <= 0.0: return 0
     return (1.0-self.strm_suspect_rate())/(1.0-StatsRouter.global_ss_mean)
 
   def circ_fail_ratio(self):
+    if 1.0-StatsRouter.global_cf_mean <= 0.0: return 0
     return (1.0-self.circ_fail_rate())/(1.0-StatsRouter.global_cf_mean)
 
   def strm_fail_ratio(self):
+    if 1.0-StatsRouter.global_sf_mean <= 0.0: return 0
     return (1.0-self.strm_fail_rate())/(1.0-StatsRouter.global_sf_mean)
 
   def current_uptime(self):