ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> modperl
modperl
directive handlers + LoadModule foo_module
by Doug MacEachern other posts by this author
Dec 29 2000 9:11PM messages near this date
Re: problems with mod_perl | RE: Where can I find....
this was reported a few times, with php as the suspect, but it happens
with any LoadModule config.  problem was that the xs module structure was
only added to the Apache module list once at startup.  it needs to be
removed/added each time apache is restarted, patch below does that.

Index: lib/Apache/ExtUtils.pm
===================================================================
RCS file: /home/cvs/modperl/lib/Apache/ExtUtils.pm,v
retrieving revision 1.21
diff -u -r1.21 ExtUtils.pm
--- lib/Apache/ExtUtils.pm	2000/12/23 02:23:09	1.21
+++ lib/Apache/ExtUtils.pm	2000/12/30 05:00:48
@@ -122,6 +122,9 @@
 sub xs_cmd_table {
     my($self, $class, $cmds) = @_;
     (my $modname = $class) =~ s/::/__/g;
+    (my $pmname = $class) =~ s,::,/,g;
+    $pmname .= '.pm';
+
     my $cmdtab = "";
     my $infos = "";
 
@@ -252,6 +255,25 @@
     NULL,   /* [1] post read_request handling */
 };
 
+#define this_module "$pmname"
+
+static void remove_module_cleanup(void *data)
+{
+    if (find_linked_module("$class")) {
+        /* need to remove the module so module index is reset */
+        remove_module(&XS_${modname});
+    }
+    if (data) {
+        /* make sure BOOT section is re-run on restarts */
+        (void)hv_delete(GvHV(incgv), this_module,
+                        strlen(this_module), G_DISCARD);
+         if (dowarn) {
+             /* avoid subroutine redefined warnings */
+             perl_clear_symtab(gv_stashpv("$class", FALSE));
+         }
+    }
+}
+
 MODULE = $class		PACKAGE = $class
 
 PROTOTYPES: DISABLE
@@ -260,14 +282,14 @@
     XS_${modname}.name = "$class";
     add_module(&XS_${modname});
     stash_mod_pointer("$class", &XS_${modname});
+    register_cleanup(perl_get_startup_pool(), (void *)1,
+                     remove_module_cleanup, null_cleanup);
 
 void
 END()
 
     CODE:
-    if (find_linked_module("$class")) {
-        remove_module(&XS_${modname});
-    }
+    remove_module_cleanup(NULL);
 EOF
 }
 
Index: src/modules/perl/mod_perl.h
===================================================================
RCS file: /home/cvs/modperl/src/modules/perl/mod_perl.h,v
retrieving revision 1.106
diff -u -r1.106 mod_perl.h
--- src/modules/perl/mod_perl.h	2000/12/20 07:24:43	1.106
+++ src/modules/perl/mod_perl.h	2000/12/30 05:00:52
@@ -1210,6 +1210,7 @@
 void perl_perl_cmd_cleanup(void *data);
 
 void perl_section_self_boot(cmd_parms *parms, void *dummy, const char *arg);
+void perl_clear_symtab(HV *symtab);
 CHAR_P perl_section (cmd_parms *cmd, void *dummy, CHAR_P arg);
 CHAR_P perl_end_section (cmd_parms *cmd, void *dummy);
 CHAR_P perl_pod_section (cmd_parms *cmd, void *dummy, CHAR_P arg);
Index: src/modules/perl/perl_config.c
===================================================================
RCS file: /home/cvs/modperl/src/modules/perl/perl_config.c,v
retrieving revision 1.107
diff -u -r1.107 perl_config.c
--- src/modules/perl/perl_config.c	2000/09/28 03:53:01	1.107
+++ src/modules/perl/perl_config.c	2000/12/30 05:00:52
@@ -1675,7 +1675,7 @@
     }   
 }
 
-static void clear_symtab(HV *symtab) 
+void perl_clear_symtab(HV *symtab) 
 {
     SV *val;
     char *key;
@@ -1686,6 +1686,7 @@
 	SV *sv;
 	HV *hv;
 	AV *av;
+	CV *cv;
 	dTHR;
 
 	if((SvTYPE(val) != SVt_PVGV) || GvIMPORTED((GV*)val))
@@ -1696,6 +1697,8 @@
 	    hv_clear(hv);
 	if((av = GvAV((GV*)val)))
 	    av_clear(av);
+	if((cv = GvCV((GV*)val)))
+	    cv_undef(cv);
     }
 }
 
@@ -1830,7 +1833,7 @@
 	if(usv && SvTRUE(usv))
 	    ; /* keep it around */
 	else
-	    clear_symtab(symtab);
+	    perl_clear_symtab(symtab);
     }
     return NULL;
 }

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved