On Mon, 2012-12-10 at 00:12 +0000, Rob Day wrote:
> The attached patch fixes that behaviour by avoiding a situation where we
> divide by zero.

The actual patch I'll be committing is below. This fixes a similar bug
where if you attempted to make more than 1 call per ms and
getmilliseconds() returned 0 (as seemed to happen on Fedora 12 and
Centos 5, but which will likely happen 0.1% of the time anywhere) the
return code would evaluate to something like (0+1 / 1.1), and casting
that to a long would truncate it to 0, meaning no calls would be set up.

Best,
Rob

--- a/opentask.cpp
+++ b/opentask.cpp
@@ -31,6 +31,7 @@
  *           Charles P Wright from IBM Research
  */
 #include "sipp.hpp"
+#define MAX(a,b) (((a)>(b))?(a):(b))
 
 class opentask *opentask::instance = NULL;
 unsigned long opentask::calls_since_last_rate_change = 0;
@@ -61,7 +62,7 @@ unsigned int opentask::wake() {
     return 0;
   } else {
     /* We need to compute when the next call is going to be opened. */
-    return (unsigned long) (last_rate_change_time +
((calls_since_last_rate_change + 1) / (rate/rate_period_ms)));
+    return (unsigned long) MAX((last_rate_change_time +
calls_since_last_rate_change) / (MAX(rate,1)/MAX(rate_period_ms,1)));
   }
 }



------------------------------------------------------------------------------
LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial
Remotely access PCs and mobile devices and provide instant support
Improve your efficiency, and focus on delivering more value-add services
Discover what IT Professionals Know. Rescue delivers
http://p.sf.net/sfu/logmein_12329d2d
_______________________________________________
Sipp-users mailing list
Sipp-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sipp-users

Reply via email to