From: Alan T. DeKok Date: Thu, 23 Feb 2012 08:25:15 +0000 (+0100) Subject: Lower the impact of auto_limit_acct when it's disabled X-Git-Tag: release_3_0_0_beta0~290 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=04ae8313b0a546f5edee514b20afc9747bd24249;p=thirdparty%2Ffreeradius-server.git Lower the impact of auto_limit_acct when it's disabled --- diff --git a/src/main/threads.c b/src/main/threads.c index 9e2407f6af2..09b635c86ad 100644 --- a/src/main/threads.c +++ b/src/main/threads.c @@ -321,11 +321,6 @@ static void reap_children(void) */ int request_enqueue(REQUEST *request) { -#ifdef WITH_STATS - int pps; - struct timeval when; -#endif - /* * If we haven't checked the number of child threads * in a while, OR if the thread pool appears to be full, @@ -340,29 +335,33 @@ int request_enqueue(REQUEST *request) pthread_mutex_lock(&thread_pool.queue_mutex); #ifdef WITH_STATS -#ifdef WITH_ACCOUTING - /* - * Throw away accounting requests if we're too busy. - */ - if ((request->packet->code == PW_ACCOUNTING_REQUEST) && - thread_pool.auto_limit_acct && - (fr_fifo_num_elements(thread_pool.fifo[RAD_LISTEN_ACCT]) > 0) && - (thread_pool.num_queued > (thread_pool.max_queue_size / 2)) && - (thread_pool.pps_in.pps_now > thread_pool.pps_out.pps_now)) { +#ifdef WITH_ACCOUNTING + if (thread_pool.auto_limit_acct) { + int pps; + struct timeval now; - pthread_mutex_unlock(&thread_pool.queue_mutex); - return 0; + /* + * Throw away accounting requests if we're too busy. + */ + if ((request->packet->code == PW_ACCOUNTING_REQUEST) && + (fr_fifo_num_elements(thread_pool.fifo[RAD_LISTEN_ACCT]) > 0) && + (thread_pool.num_queued > (thread_pool.max_queue_size / 2)) && + (thread_pool.pps_in.pps_now > thread_pool.pps_out.pps_now)) { + + pthread_mutex_unlock(&thread_pool.queue_mutex); + return 0; + } + + gettimeofday(&now, NULL); + + pps = rad_pps(&thread_pool.pps_in.pps_old, + &thread_pool.pps_in.pps_now, + &thread_pool.pps_in.time_old, + &now); + + thread_pool.pps_in.pps_now++; } #endif /* WITH_ACCOUNTING */ - - gettimeofday(&when, NULL); - - pps = rad_pps(&thread_pool.pps_in.pps_old, - &thread_pool.pps_in.pps_now, - &thread_pool.pps_in.time_old, - &when); - - thread_pool.pps_in.pps_now++; #endif thread_pool.request_count++; @@ -427,22 +426,25 @@ static int request_dequeue(REQUEST **prequest) static time_t last_complained; RAD_LISTEN_TYPE i, start; REQUEST *request; -#ifdef WITH_STATS - int pps; - struct timeval now; -#endif reap_children(); pthread_mutex_lock(&thread_pool.queue_mutex); #ifdef WITH_STATS - gettimeofday(&now, NULL); - - pps = rad_pps(&thread_pool.pps_out.pps_old, - &thread_pool.pps_out.pps_now, - &thread_pool.pps_out.time_old, - &now); - thread_pool.pps_out.pps_now++; +#ifdef WITH_ACCOUNTING + if (thread_pool.auto_limit_acct) { + int pps; + struct timeval now; + + gettimeofday(&now, NULL); + + pps = rad_pps(&thread_pool.pps_out.pps_old, + &thread_pool.pps_out.pps_now, + &thread_pool.pps_out.time_old, + &now); + thread_pool.pps_out.pps_now++; + } +#endif #endif /*