Пример #1
0
void client_add_worker (client_t *client)
{
    worker_t *handler;

    thread_rwlock_rlock (&workers_lock);
    /* add client to the handler with the least number of clients */
    handler = worker_selected();
    thread_spin_lock (&handler->lock);
    thread_rwlock_unlock (&workers_lock);

    worker_add_client (handler, client);
    thread_spin_unlock (&handler->lock);
    worker_wakeup (handler);
}
Пример #2
0
static int fserve_change_worker (client_t *client)
{
    worker_t *this_worker = client->worker, *worker;
    int ret = 0;

    if (this_worker->move_allocations == 0 || worker_count < 2)
        return 0;
    thread_rwlock_rlock (&workers_lock);
    worker = worker_selected ();
    if (worker && worker != client->worker)
    {
        long diff = this_worker->count - worker->count;
        if (diff > 15)
        {
            this_worker->move_allocations--;
            ret = client_change_worker (client, worker);
            if (ret)
                DEBUG2 ("moving listener from %p to %p", this_worker, worker);
        }
    }
    thread_rwlock_unlock (&workers_lock);
    return ret;
}