static THREAD_POOL thread_pool;
static int pool_initialized = FALSE;
-static time_t almost_now = 0;
#ifndef WITH_GCD
static time_t last_cleaned = 0;
*/
int request_enqueue(REQUEST *request)
{
- static int last_complained = 0;
-
- almost_now = request->timestamp;
-
/*
* If we haven't checked the number of child threads
* in a while, OR if the thread pool appears to be full,
thread_pool.request_count++;
- if ((thread_pool.num_queued >= thread_pool.max_queue_size) &&
- (last_complained != almost_now)) {
- last_complained = almost_now;
+ if (thread_pool.num_queued >= thread_pool.max_queue_size) {
+ int complain = FALSE;
+ time_t now;
+ static time_t last_complained = 0;
+ now = time(NULL);
+ if (last_complained != now) {
+ last_complained = now;
+ complain = TRUE;
+ }
+
pthread_mutex_unlock(&thread_pool.queue_mutex);
/*
* Mark the request as done.
*/
- radlog(L_ERR, "Something is blocking the server. There are %d packets in the queue, waiting to be processed. Ignoring the new request.", thread_pool.max_queue_size);
+ if (complain) {
+ radlog(L_ERR, "Something is blocking the server. There are %d packets in the queue, waiting to be processed. Ignoring the new request.", thread_pool.max_queue_size);
+ }
return 0;
}
request->component = "<core>";
*/
static int request_dequeue(REQUEST **prequest)
{
- int blocked;
+ time_t blocked;
+ static time_t last_complained;
RAD_LISTEN_TYPE i, start;
REQUEST *request;
}
/*
- * Produce messages for people who have 10 million rows
- * in a database, without indexes.
+ * The thread is currently processing a request.
*/
- rad_assert(almost_now != 0);
- blocked = almost_now - request->timestamp;
- if (blocked < 5) {
- blocked = 0;
- } else {
- static time_t last_complained = 0;
-
- if (last_complained != almost_now) {
- last_complained = almost_now;
+ thread_pool.active_threads++;
+
+ blocked = time(NULL);
+ if ((blocked - request->timestamp) > 5) {
+ if (last_complained < blocked) {
+ blocked -= request->timestamp;
} else {
blocked = 0;
}
+ } else {
+ blocked = 0;
}
- /*
- * The thread is currently processing a request.
- */
- thread_pool.active_threads++;
-
pthread_mutex_unlock(&thread_pool.queue_mutex);
if (blocked) {
radlog(L_ERR, "Request %u has been waiting in the processing queue for %d seconds. Check that all databases are running properly!",
- request->number, blocked);
+ request->number, (int) blocked);
}
return 1;