void PreforkBridge_ChildInit()

in src/mod_rivet_ng/rivet_prefork_mpm.c [63:117]


void PreforkBridge_ChildInit (apr_pool_t* pool, server_rec* server)
{
    rivet_server_conf*      rsc = RIVET_SERVER_CONF (module_globals->server->module_config);
    rivet_thread_private*   private;

    ap_assert (apr_threadkey_private_create (&rivet_thread_key, NULL, pool) == APR_SUCCESS);

    /*
     * This is the only execution thread in this process so we create
     * the Tcl thread private data here. In a fork capable OS
     * private data should have been created by the httpd parent process
     */

    private = Rivet_ExecutionThreadInit();
    private->ext = apr_pcalloc(private->pool,sizeof(mpm_bridge_specific));
    private->ext->interps =
        apr_pcalloc(private->pool,module_globals->vhosts_count*sizeof(rivet_thread_interp));


    /* we now establish the full rivet core command set for the root interpreter */

    Rivet_InitCore (module_globals->server_interp->interp,private);

    /* The root interpreter is created without a rivet cache (that wouldn't make sense
     * in that context. We create the cache now */

    module_globals->server_interp->cache_size = rsc->default_cache_size;
    if (module_globals->server_interp->cache_size < 0) {
        module_globals->server_interp->cache_size = RivetCache_DefaultSize();
    }
    module_globals->server_interp->cache_free = module_globals->server_interp->cache_size;
    ap_log_error(APLOG_MARK,APLOG_DEBUG,APR_SUCCESS,server,"root interpreter cache size: %d (free: %d)",
                                                            module_globals->server_interp->cache_size,
                                                            module_globals->server_interp->cache_free);

    RivetCache_Create(module_globals->pool,module_globals->server_interp);

#ifdef RIVET_NAMESPACE_IMPORT
    {
        char* tcl_import_cmd = "namespace eval :: { namespace import -force ::rivet::* }\n";

        Tcl_Eval (module_globals->server_interp->interp,tcl_import_cmd);
    }
#endif

    /*
     * We proceed creating the vhost interpreters database
     */

    if (Rivet_VirtualHostsInterps(private) == NULL)
    {
        ap_log_error(APLOG_MARK, APLOG_ERR, APR_EGENERAL, server, MODNAME ": Tcl Interpreters creation fails");
        exit(1);
    }
}