static int request_add(int a, int b){ request_queue_entry* e; e = new_request_queue_entry(); e->method = METHOD_ADD; e->param.request_add.a = a; e->param.request_add.b = b; request_enqueue(e); uvm_chime_wait(&e->chime); dispose_request_queue_entry(e); return e->result.result_add.result; }
/* * Assign a new request to a free thread. * * If there isn't a free thread, then try to create a new one, * up to the configured limits. */ int thread_pool_addrequest(REQUEST *request, RAD_REQUEST_FUNP fun) { time_t now = request->timestamp; request->process = fun; /* * We've been told not to spawn threads, so don't. */ if (!thread_pool.spawn_flag) { radius_handle_request(request, fun); #ifdef WNOHANG /* * Requests that care about child process exit * codes have already either called * rad_waitpid(), or they've given up. */ wait(NULL); #endif return 1; } /* * Add the new request to the queue. */ if (!request_enqueue(request, fun)) return 0; /* * If we haven't checked the number of child threads * in a while, OR if the thread pool appears to be full, * go manage it. */ if ((last_cleaned < now) || (thread_pool.active_threads == thread_pool.total_threads)) { thread_pool_manage(now); } return 1; }