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
sayer/1.4-spce2.6
Stefan Sayer 15 years ago committed by Stefan Sayer
parent fa0614f40b
commit 6878d44d11

@ -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;
}

Loading…
Cancel
Save