gozer       2004/08/25 13:57:15

  Modified:    .        Changes
               src/modules/perl modperl_mgv.c modperl_util.c
  Log:
  modperl_perl_module_loaded() fixed to use %INC to determine if a module
  is loaded instead of checking for the existence of a stash.
  
  Use Foo::Bar::Baz creates Foo:: Foo::Bar:: _and_ Foo::Bar::Baz:: stashes,
  so before this mp_module_loaded() would tell you Foo and Foo::Bar were
  loaded.
  
  Revision  Changes    Path
  1.468     +3 -0      modperl-2.0/Changes
  
  Index: Changes
  ===================================================================
  RCS file: /home/cvs/modperl-2.0/Changes,v
  retrieving revision 1.467
  retrieving revision 1.468
  diff -u -r1.467 -r1.468
  --- Changes   25 Aug 2004 17:20:04 -0000      1.467
  +++ Changes   25 Aug 2004 20:57:14 -0000      1.468
  @@ -12,6 +12,9 @@
   
   =item 1.99_17-dev
   
  +modperl_perl_module_loaded() fixed to use %INC to determine if a module
  +is loaded instead of checking for the existence of a stash [Gozer]
  +
   fix the modperl build, where httpd has been built against separate
   installations of apr-util and apr, where apr-util has been installed
   with a different includedir to apr. [Joe Orton]
  
  
  
  1.36      +4 -39     modperl-2.0/src/modules/perl/modperl_mgv.c
  
  Index: modperl_mgv.c
  ===================================================================
  RCS file: /home/cvs/modperl-2.0/src/modules/perl/modperl_mgv.c,v
  retrieving revision 1.35
  retrieving revision 1.36
  diff -u -r1.35 -r1.36
  --- modperl_mgv.c     4 Mar 2004 06:01:07 -0000       1.35
  +++ modperl_mgv.c     25 Aug 2004 20:57:14 -0000      1.36
  @@ -171,32 +171,6 @@
   }
   #endif
   
  -
  -static void package2filename(apr_pool_t *p, const char *package,
  -                             char **filename, int *len)
  -{
  -    const char *s;
  -    char *d;
  -
  -    *filename = apr_palloc(p, (strlen(package)+4)*sizeof(char));
  -
  -    for (s = package, d = *filename; *s; s++, d++) {
  -        if (*s == ':' && s[1] == ':') {
  -            *d = '/';
  -            s++;
  -        }
  -        else {
  -            *d = *s;
  -        }
  -    }
  -    *d++ = '.';
  -    *d++ = 'p';
  -    *d++ = 'm';
  -    *d   = '\0';
  -
  -    *len = d - *filename;
  -}
  -
   /* currently used for complex filters attributes parsing */
   /* XXX: may want to generalize it for any handlers */
   #define MODPERL_MGV_DEEP_RESOLVE(handler, p) \
  @@ -281,17 +255,10 @@
       }
   
       if (!stash && MpHandlerAUTOLOAD(handler)) {
  -        int len;
  -        char *filename;
  -        SV **svp;
  -
  -        package2filename(p, name, &filename, &len);
  -        svp = hv_fetch(GvHVn(PL_incgv), filename, len, 0);
  -
  -        if (!(svp && *svp != &PL_sv_undef)) { /* not in %INC */
  +        if (!modperl_perl_module_loaded(aTHX_ name)) { /* not in %INC */
               MP_TRACE_h(MP_FUNC,
  -                       "package %s not in %INC, attempting to load '%s'\n",
  -                       name, filename);
  +                       "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);
  @@ -309,9 +276,7 @@
               }
           }
           else {
  -            MP_TRACE_h(MP_FUNC, "package %s seems to be loaded\n"
  -                       "  $INC{'%s')='%s';\n",
  -                       name, filename, SvPV_nolen(*svp));
  +            MP_TRACE_h(MP_FUNC, "package %s seems to be loaded\n", name);
           }
       }
   
  
  
  
  1.77      +33 -1     modperl-2.0/src/modules/perl/modperl_util.c
  
  Index: modperl_util.c
  ===================================================================
  RCS file: /home/cvs/modperl-2.0/src/modules/perl/modperl_util.c,v
  retrieving revision 1.76
  retrieving revision 1.77
  diff -u -r1.76 -r1.77
  --- modperl_util.c    22 Aug 2004 20:47:37 -0000      1.76
  +++ modperl_util.c    25 Aug 2004 20:57:14 -0000      1.77
  @@ -486,9 +486,41 @@
       return retval;
   }
   
  +static char *package2filename(const char *package, int *len)
  +{
  +    const char *s;
  +    char *d;
  +    char *filename;
  +
  +    filename = malloc((strlen(package)+4)*sizeof(char));
  +
  +    for (s = package, d = filename; *s; s++, d++) {
  +        if (*s == ':' && s[1] == ':') {
  +            *d = '/';
  +            s++;
  +        }
  +        else {
  +            *d = *s;
  +        }
  +    }
  +    *d++ = '.';
  +    *d++ = 'p';
  +    *d++ = 'm';
  +    *d   = '\0';
  +
  +    *len = d - filename;
  +    return filename;
  +}
  +
   MP_INLINE int modperl_perl_module_loaded(pTHX_ const char *name)
   {
  -    return (*name && gv_stashpv(name, FALSE)) ? 1 : 0;
  +    SV **svp;
  +    int len;
  +    char *filename = package2filename(name, &len);
  +    svp = hv_fetch(GvHVn(PL_incgv), filename, len, 0);
  +    free(filename);
  +
  +    return (svp && *svp != &PL_sv_undef) ? 1 : 0;
   }
   
   static int modperl_gvhv_is_stash(GV *gv)
  
  
  

Reply via email to