in src/mod_rivet_ng/rivet_lazy_mpm.c [444:495]
apr_status_t LazyBridge_Finalize (void* data)
{
int idx;
server_rec* server = (server_rec*) data;
rivet_server_conf* conf = RIVET_SERVER_CONF(server->module_config);
module_globals->mpm->server_shutdown = 1;
for (idx = 0; idx < module_globals->vhosts_count; idx++)
{
int try;
int count;
apr_array_header_t* array;
apr_thread_mutex_t* mutex;
mutex = module_globals->mpm->vhosts[idx].mutex;
array = module_globals->mpm->vhosts[idx].array;
/* we need to lock the vhost data mutex */
apr_thread_mutex_lock(mutex);
count = module_globals->mpm->vhosts[idx].threads_count;
apr_thread_mutex_unlock(mutex);
try = 0;
while ((try++ < 3) && (count > 0))
{
ap_log_error(APLOG_MARK,APLOG_DEBUG,APR_SUCCESS,server,"waiting for %d thread to exit",count);
if ((conf->idx == idx) && (count == 1)) { break; }
while (!apr_is_empty_array(array))
{
lazy_tcl_worker* w;
w = *(lazy_tcl_worker**) apr_array_pop(array);
apr_thread_mutex_lock(w->mutex);
w->r = NULL;
w->status = thread_exit;
apr_thread_cond_signal(w->condition);
apr_thread_mutex_unlock(w->mutex);
}
apr_thread_mutex_lock(mutex);
count = module_globals->mpm->vhosts[idx].threads_count;
apr_thread_mutex_unlock(mutex);
apr_sleep(1000);
}
}
return APR_SUCCESS;
}