Module: sems
Branch: master
Commit: a72f959d4db1065b849d0d49332772dc6410a536
URL:    
http://git.sip-router.org/cgi-bin/gitweb.cgi/sems/?a=commit;h=a72f959d4db1065b849d0d49332772dc6410a536

Author: Stefan Sayer <[email protected]>
Committer: Stefan Sayer <[email protected]>
Date:   Thu Jun  9 16:10:55 2011 +0200

b/f: db_reg_agent: fixed ratelimit

fixed ratelimiting, which would otherwise limit at about two times
the rate

thanks to Vlada B for reporting

---

 apps/db_reg_agent/DBRegAgent.cpp |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/apps/db_reg_agent/DBRegAgent.cpp b/apps/db_reg_agent/DBRegAgent.cpp
index 47c4e96..f2fbac0 100644
--- a/apps/db_reg_agent/DBRegAgent.cpp
+++ b/apps/db_reg_agent/DBRegAgent.cpp
@@ -1073,7 +1073,7 @@ void DBRegAgentProcessorThread::rateLimitWait() {
   struct timeval time_passed;
   gettimeofday(&current, 0);
   timersub(&current, &last_check, &time_passed);
-  last_check = current;
+  memcpy(&last_check, &current, sizeof(struct timeval));
   double seconds_passed = (double)time_passed.tv_sec +
     (double)time_passed.tv_usec / 1000000.0;
   allowance += seconds_passed * 
@@ -1087,6 +1087,7 @@ void DBRegAgentProcessorThread::rateLimitWait() {
     DBG("not enough allowance (%f), sleeping %d useconds\n", allowance, 
sleep_time);
     usleep(sleep_time);
     allowance=0.0;
+    gettimeofday(&last_check, 0);
   } else {
     allowance -= 1.0;
   }

_______________________________________________
Semsdev mailing list
[email protected]
http://lists.iptel.org/mailman/listinfo/semsdev

Reply via email to