perl-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Philippe M. Chiasson" <go...@cpan.org>
Subject [Patch mp1] WAS: mp_preload_module() bustage
Date Wed, 18 Jun 2003 04:36:09 GMT
Finally got around fixing it ;-)


# $Id: mp_preload_module.patch,v 1.1 2003/06/18 04:35:01 gozer Exp $
Index: src/modules/perl/perl_config.c
===================================================================
RCS file: /home/cvs/modperl/src/modules/perl/perl_config.c,v
retrieving revision 1.117
diff -u -I$Id -r1.117 perl_config.c
--- src/modules/perl/perl_config.c	14 Mar 2003 04:55:59 -0000	1.117
+++ src/modules/perl/perl_config.c	18 Jun 2003 04:34:14 -0000
@@ -424,19 +424,30 @@
 #ifdef WIN32
 #define mp_preload_module(name)
 #else
-static void mp_preload_module(char **name)
+static void mp_preload_module(pool *p, char **name)
 {
+    char *endp, *mod_name;
     if(ind(*name, ' ') >= 0) return;
     if(**name == '-' && ++*name) return;
+    if(**name == '$') return;
     if(**name == '+') ++*name;
-    else if(!PERL_AUTOPRELOAD) return;
+    
+    if(!PERL_AUTOPRELOAD) return;
     if(!PERL_RUNNING()) return;
 
-    if(!perl_module_is_loaded(*name)) { 
+    if(endp =  strstr(*name, "->")) {
+        mod_name = pstrdup(p, *name);
+        mod_name[endp-*name] = '\0';
+    }
+    else {
+        mod_name = *name;
+    }
+
+    if(!perl_module_is_loaded(mod_name)) { 
 	MP_TRACE_d(fprintf(stderr, 
 			   "mod_perl: attempting to pre-load module `%s'\n", 
-			   *name));
-	perl_require_module(*name,NULL);
+			   mod_name));
+	perl_require_module(mod_name,NULL);
     }
 }
 #endif
@@ -453,7 +464,7 @@
 CHAR_P perl_cmd_push_handlers(char *hook, PERL_CMD_TYPE **cmd, char *arg, pool *p)
 { 
     SV *sva;
-    mp_preload_module(&arg);
+    mp_preload_module(p, &arg);
     sva = newSVpv(arg,0); 
     if(!*cmd) { 
         *cmd = newAV(); 
@@ -474,7 +485,7 @@
 
 #define PERL_CMD_PUSH_HANDLERS(hook, cmd) \
 STARTUP_PERL_IF_NOT_RUNNING \
-mp_preload_module(&arg); \
+mp_preload_module(cmd->pool, &arg); \
 cmd = arg; \
 return NULL
 
@@ -2048,4 +2059,3 @@
 
     return perl_hook_api(name);
 }
-

On Thu, 2003-06-12 at 22:18, Geoffrey Young wrote:
> >>so, I suspect that most people figure it out when the module doesn't work as

> >>expected, preload the module, and don't see a problem.
> > 
> > 
> > Well, preloading will sure fix the breakage, but you will still get one
> > strange _extra_ call to that method with no $r on startup.
> 
> yeah, now that you mention it, that's not good.
> 
> > 
> > 
> >>does that seem to gel with what you've found?
> > 
> > 
> > Sure does! I figured if I looked back in the mlist archives I might find
> > something like this. Thanks for the insight then Geoff !
> 
> :)
> 
> > 
> > It also means that mp_preload_module is indeed broken and will be fixed
> > shortly ;-) Unless anybody beats me to it, that is.
> 
> cool.
> 
> nice work keeping up with all the 1.3 stuff, philippe.

No problem, just doing my part ;-)

> --Geoff
-- 
--------------------------------------------------------------------------------
Philippe M. Chiasson /gozer\@(cpan|ectoplasm)\.org/ 88C3A5A5 (122FF51B/C634E37B)
http://gozer.ectoplasm.org/    F9BF E0C2 480E 7680 1AE5 3631 CB32 A107 88C3 A5A5
Q: It is impossible to make anything foolproof because fools are so ingenious.
perl -e'$$=\${gozer};{$_=unpack(P7,pack(L,$$));/^JAm_pH\n$/&&print||$$++&&redo}'


Mime
View raw message