MP_TRACE_h(MP_FUNC, "failied to load %s package\n", name);
MP_TRACE_h(MP_FUNC, "failed to load %s package\n", name);
int modperl_mgv_resolve(pTHX_ modperl_handler_t *handler,                        apr_pool_t *p, const char *name, int logfailure){    CV *cv;    GV *gv;    HV *stash = Nullhv;    char *handler_name = "handler";    char *tmp;    if (MpHandlerANON(handler)) {        /* already resolved anonymous handler */        return 1;    }        if (strnEQ(name, "sub ", 4)) {        MP_TRACE_h(MP_FUNC, "handler is anonymous\n");        MpHandlerANON_On(handler);        MpHandlerPARSED_On(handler);        return 1;    }    if ((tmp = strstr((char *)name, "->"))) {        int package_len = strlen(name) - strlen(tmp);        char *package = apr_pstrndup(p, name, package_len);        name = package;        handler_name = &tmp[2];        MpHandlerMETHOD_On(handler);        if (*package == '$') {            GV *gv;            SV *obj;            handler->mgv_obj = modperl_mgv_compile(aTHX_ p, package + 1);            gv = modperl_mgv_lookup(aTHX_ handler->mgv_obj);            obj = gv ? GvSV(gv) : Nullsv;            if (SvTRUE(obj)) {                if (SvROK(obj) && sv_isobject(obj)) {                    stash = SvSTASH(SvRV(obj));                    MpHandlerOBJECT_On(handler);                    MP_TRACE_h(MP_FUNC, "handler object %s isa %s\n",                               package, HvNAME(stash));                }                else {                    MP_TRACE_h(MP_FUNC, "%s is not an object, pv=%s\n",                               package, SvPV_nolen(obj));                    return 0;                }            }            else {                MP_TRACE_h(MP_FUNC, "failed to thaw %s\n", package);                return 0;            }        }        if (!stash) {            if ((stash = gv_stashpvn(package, package_len, FALSE))) {                MP_TRACE_h(MP_FUNC, "handler method %s isa %s\n",                           name, HvNAME(stash));            }        }    }    else {        if ((cv = get_cv(name, FALSE))) {            handler->attrs = (U32)MP_CODE_ATTRS(cv);            handler->mgv_cv =                modperl_mgv_compile(aTHX_ p, HvNAME(GvSTASH(CvGV(cv))));            modperl_mgv_append(aTHX_ p, handler->mgv_cv, GvNAME(CvGV(cv)));            MpHandlerPARSED_On(handler);            MODPERL_MGV_DEEP_RESOLVE(handler, p);            return 1;        }    }    if (!stash && MpHandlerAUTOLOAD(handler)) {        if (!modperl_perl_module_loaded(aTHX_ name)) { /* not in %INC */            MP_TRACE_h(MP_FUNC,                       "package %s not in %INC, attempting to load it\n",                       name);            if (modperl_require_module(aTHX_ name, logfailure)) {                MP_TRACE_h(MP_FUNC, "loaded %s package\n", name);            }            else {                if (logfailure) {                    /* the caller doesn't handle the error checking */                    Perl_croak(aTHX_ "failed to load %s package\n", name);                }                else {                    /* the caller handles the error checking */                    MP_TRACE_h(MP_FUNC, "failied to load %s package\n", name);                    return 0;                }            }        }        else {            MP_TRACE_h(MP_FUNC, "package %s seems to be loaded\n", name);        }    }    /* try to lookup the stash only after loading the module, to avoid     * the case where a stash is autovivified by a user before the     * module was loaded, preventing from loading the module     */    if (!(stash || (stash = gv_stashpv(name, FALSE)))) {        MP_TRACE_h(MP_FUNC, "%s's stash is not found\n", name);        return 0;    }    if ((gv = gv_fetchmethod(stash, handler_name)) && (cv = GvCV(gv))) {        if (CvFLAGS(cv) & CVf_METHOD) { /* sub foo : method {}; */            MpHandlerMETHOD_On(handler);        }        if (MpHandlerMETHOD(handler) && !handler->mgv_obj) {            modperl_mgv_new_name(handler->mgv_obj, p, HvNAME(stash));        }        handler->attrs = (U32)MP_CODE_ATTRS(cv);        /* note: this is the real function after @ISA lookup */        handler->mgv_cv = modperl_mgv_compile(aTHX_ p, HvNAME(GvSTASH(gv)));        modperl_mgv_append(aTHX_ p, handler->mgv_cv, handler_name);          MpHandlerPARSED_On(handler);        MP_TRACE_h(MP_FUNC, "[%s] found `%s' in class `%s' as a %s\n",                   modperl_pid_tid(p),                   handler_name, HvNAME(stash),                   MpHandlerMETHOD(handler) ? "method" : "function");        MODPERL_MGV_DEEP_RESOLVE(handler, p);        return 1;    }    /* at least modperl_hash_handlers needs to verify that an     * autoloaded-marked handler needs to be loaded, since it doesn't     * check success failure, and handlers marked to be autoloaded are     * the same as PerlModule and the failure should be fatal */    if (MpHandlerAUTOLOAD(handler)) {        Perl_croak(aTHX_ "failed to resolve handler %s\n", name);    }    #ifdef MP_TRACE    /* complain only if the class was actually loaded/created */    if (stash) {        MP_TRACE_h(MP_FUNC, "`%s' not found in class `%s'\n",                   handler_name, name);    }#endif    return 0;}