static void Lazy_RunConfScript()

in src/mod_rivet_ng/rivet_lazy_mpm.c [96:144]


static void Lazy_RunConfScript (rivet_thread_private* private,lazy_tcl_worker* w,int init)
{
    Tcl_Obj*    tcl_conf_script;
    Tcl_Interp* interp = private->ext->interp->interp;
    void*       function = NULL;

    switch (init)
    {
        case child_global: function = w->conf->rivet_global_init_script;
                           break;
        case child_init: function = w->conf->rivet_child_init_script;
                         break;
        case child_exit: function = w->conf->rivet_child_exit_script;
    }

    if (function)
    {
        rivet_interp_globals* globals = NULL;
        tcl_conf_script = Tcl_NewStringObj(function,-1);
        Tcl_IncrRefCount(tcl_conf_script);

        /* before we run a script we have to store the pointer to the
         * running configuration in the thread private data. The design has
         * to improve and running a script must have everything sanely
         * prepared TODO
         */

        globals = Tcl_GetAssocData(interp,"rivet",NULL);

        /*
         * The current server record is stored to enable ::rivet::apache_log_error and
         * other commands to log error messages in the virtual host's designated log file
         */

        globals->server = w->server;

        if (Tcl_EvalObjEx(interp,tcl_conf_script, 0) != TCL_OK)
        {
            char*       errmsg = "rivet_lazy_mpm.so: Error in configuration script: %s";
            server_rec* root_server = module_globals->server;

            ap_log_error(APLOG_MARK,APLOG_ERR,APR_EGENERAL,root_server,errmsg,function);
            ap_log_error(APLOG_MARK,APLOG_ERR,APR_EGENERAL,root_server,"errorCode: %s", Tcl_GetVar(interp, "errorCode", 0));
            ap_log_error(APLOG_MARK,APLOG_ERR,APR_EGENERAL,root_server,"errorInfo: %s", Tcl_GetVar(interp, "errorInfo", 0));
        }

        Tcl_DecrRefCount(tcl_conf_script);
    }
}