From 6878d44d11eae7c74dbaf435464e6a2f811b55ba Mon Sep 17 00:00:00 2001 From: Stefan Sayer Date: Thu, 9 Jun 2011 16:10:55 +0200 Subject: [PATCH] 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 file changed, 2 insertions(+), 1 deletion(-) diff --git a/apps/db_reg_agent/DBRegAgent.cpp b/apps/db_reg_agent/DBRegAgent.cpp index 47c4e969..f2fbac0f 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(¤t, 0); timersub(¤t, &last_check, &time_passed); - last_check = current; + memcpy(&last_check, ¤t, 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; }