apr_status_t procmgr_stop_procmgr()

in modules/fcgid/fcgid_pm_win.c [267:300]


apr_status_t procmgr_stop_procmgr(void *server)
{
    apr_status_t status;
    fcgid_server_conf *conf;

    /* Tell the world to die */
    g_must_exit = 1;
    if (g_msgqueue)
        apr_queue_push(g_msgqueue, NULL);

    /* Wait */
    if (g_thread && apr_thread_join(&status, g_thread) == APR_SUCCESS) {
        /* Free the memory left in queue */
        fcgid_command *peakcmd = NULL;

        while (apr_queue_trypop(g_msgqueue, (void **)&peakcmd) == APR_SUCCESS) {
            if (peakcmd)
                free(peakcmd);
        }
    }

    /* Clean up the Job object if present */
    conf = ap_get_module_config(((server_rec*)server)->module_config,
                                &fcgid_module);

    if (conf->hJobObjectForAutoCleanup != NULL) {
        CloseHandle(conf->hJobObjectForAutoCleanup);
    }

    if (g_wakeup_thread)
        return apr_thread_join(&status, g_wakeup_thread);

    return APR_SUCCESS;
}