if (MpDirSETUP_ENV(dcfg)) { modperl_env_request_populate(aTHX_ r); }
int modperl_callback_run_handlers(int idx, int type,                                  request_rec *r, conn_rec *c, server_rec *s,                                  apr_pool_t *pconf,                                  apr_pool_t *plog,                                  apr_pool_t *ptemp){#ifdef USE_ITHREADS    pTHX;    modperl_interp_t *interp = NULL;#endif    MP_dSCFG(s);    MP_dDCFG;    MP_dRCFG;    modperl_handler_t **handlers;    apr_pool_t *p = NULL;    MpAV *av, **avp;    int i, status = OK;    const char *desc = NULL;    AV *av_args = Nullav;    if (!MpSrvENABLE(scfg)) {        MP_TRACE_h(MP_FUNC, "PerlOff for server %s\n",                   s->server_hostname);        return DECLINED;    }    if (r || c) {        p = c ? c->pool : r->pool;    }    else {        p = pconf;    }    avp = modperl_handler_lookup_handlers(dcfg, scfg, rcfg, p,                                          type, idx, FALSE, &desc);    if (!(avp && (av = *avp))) {        MP_TRACE_h(MP_FUNC, "no %s handlers configured (%s)\n",                   desc, r ? r->uri : "");        return DECLINED;    }#ifdef USE_ITHREADS    if (r && !c && modperl_interp_scope_connection(scfg)) {        c = r->connection;    }    if (r || c) {        interp = modperl_interp_select(r, c, s);        aTHX = interp->perl;    }    else {        /* Child{Init,Exit}, OpenLogs */        aTHX = scfg->mip->parent->perl;        PERL_SET_CONTEXT(aTHX);    }#endif    switch (type) {      case MP_HANDLER_TYPE_PER_DIR:      case MP_HANDLER_TYPE_PER_SRV:        modperl_handler_make_args(aTHX_ &av_args,                                  "Apache::RequestRec", r, NULL);        break;      case MP_HANDLER_TYPE_CONNECTION:        modperl_handler_make_args(aTHX_ &av_args,                                  "Apache::Connection", c, NULL);        break;      case MP_HANDLER_TYPE_FILES:        modperl_handler_make_args(aTHX_ &av_args,                                  "Apache::Pool", pconf,                                  "Apache::Pool", plog,                                  "Apache::Pool", ptemp,                                  "Apache::Server", s, NULL);        break;      case MP_HANDLER_TYPE_PROCESS:        modperl_handler_make_args(aTHX_ &av_args,                                  "Apache::Pool", pconf,                                  "Apache::Server", s, NULL);        break;    };    /* XXX: deal with {push,set}_handler of the phase we're currently in */    MP_TRACE_h(MP_FUNC, "running %d %s handlers\n",               av->nelts, desc);    handlers = (modperl_handler_t **)av->elts;    for (i=0; i<av->nelts; i++) {        if ((status = modperl_callback(aTHX_ handlers[i], p, s, av_args)) != OK) {            status = modperl_errsv(aTHX_ status, r, s);        }        MP_TRACE_h(MP_FUNC, "%s returned %d\n",                   handlers[i]->name, status);    }    SvREFCNT_dec((SV*)av_args);#ifdef USE_ITHREADS    if (interp && MpInterpPUTBACK(interp)) {        /* PerlInterpScope handler */        modperl_interp_unselect(interp);    }#endif    return status;}