예제 #1
0
// We pick a worker (consequetive) and set a max number of clients to move if needed
void worker_balance_trigger (time_t now)
{
    int log_counts = (now % 10) == 0 ? 1 : 0;

    if (worker_count == 1)
        return; // no balance required, leave quickly
    thread_rwlock_rlock (&workers_lock);

    // lets only search for this once a second, not many times
    worker_least_used = find_least_busy_handler (log_counts);
    if (worker_balance_to_check)
    {
        worker_balance_to_check->move_allocations = 50;
        worker_balance_to_check = worker_balance_to_check->next;
    }
    if (worker_balance_to_check == NULL)
        worker_balance_to_check = workers;

    thread_rwlock_unlock (&workers_lock);
}
예제 #2
0
// We pick a worker (consequetive) and set a max number of clients to move if needed
void worker_balance_trigger (time_t now)
{

    thread_rwlock_rlock (&workers_lock);
    if (worker_count > 1)
    {
        int log_counts = (now & 15) == 0 ? 1 : 0;

        worker_least_used = find_least_busy_handler (log_counts);
        if (worker_balance_to_check)
        {
            worker_balance_to_check->move_allocations = 50;
            worker_balance_to_check = worker_balance_to_check->next;
        }
        if (worker_balance_to_check == NULL)
            worker_balance_to_check = workers;
    }
    if (worker_incoming)
        worker_incoming->move_allocations = 2000000; // enforce a move away from this thread if possible

    thread_rwlock_unlock (&workers_lock);
}
예제 #3
0
worker_t *worker_selected (void)
{
    if ((worker_least_used->count + worker_least_used->pending_count) - worker_min_count > 20)
        worker_least_used = find_least_busy_handler(1);
    return worker_least_used;
}