in src/mod_rivet_ng/rivet_worker_mpm.c [133:184]
void WorkerBridge_Shutdown (void)
{
int waits;
void* v;
handler_private* thread_obj;
apr_status_t rv;
apr_uint32_t threads_to_stop = 0;
int not_to_be_waited;
not_to_be_waited = module_globals->mpm->skip_thread_on_exit;
apr_thread_mutex_lock(module_globals->mpm->job_mutex);
module_globals->mpm->server_shutdown = 1;
/* We wake up the supervisor who is now supposed to stop
* all the Tcl worker threads
*/
apr_thread_cond_signal(module_globals->mpm->job_cond);
apr_thread_mutex_unlock(module_globals->mpm->job_mutex);
waits = 5;
do
{
rv = apr_queue_trypop(module_globals->mpm->queue,&v);
/* We wait for possible threads that are taking
* time to serve requests and haven't had a chance to
* see the signal yet
*/
if (rv == APR_EAGAIN)
{
waits--;
apr_sleep(200000);
continue;
}
thread_obj = (handler_private*)v;
apr_thread_mutex_lock(thread_obj->mutex);
thread_obj->status = init;
apr_thread_cond_signal(thread_obj->cond);
apr_thread_mutex_unlock(thread_obj->mutex);
threads_to_stop = apr_atomic_read32(module_globals->mpm->threads_count);
} while ((waits > 0) && (threads_to_stop > not_to_be_waited));
return;
}