OK I've finally wrapped my head around how things work at the server
startup.
This [the patch at the bottom] is a crude proof of concept code for
PerlModule. Before I wrap it all nicely, please tell me if that's more or
less how things should be done. This is my first take on adding a new
feature for 2.0 at the C side :)
Should I provide a test for things like PerlModule/PerlRequire or these
are core features and they are supposed to work? If the test is a good
thing, I suppose i should write some unique module and require it and not
some widely available module. since it's possible that I pick some module
that will be loaded from a different place in the startup code and then
the test wouldn't prove that the functionality works properly (e.g.
assuming that PerlRequire startup.pl loads some module via 'use' and then
the test is not testing anything.
- In case of the module/file require failure, should only the warning be
printed or should the process abort its execution?
Another question is about a definition of how do we want PerlModule to
work:
- load modules in the parent interpreter and let all children inherit from
it.
- allow each vhost to have its own preloaded modules.
- allow each interpteter pool have its own preloaded modules (which is
probably the same as the prev item, right?)
>From one side sharing all the preloaded modules is a great benefit because
of the shared optree, on the other hand if these modules have some big
data structures in them at the init time, this data will be inhereted by
all tipools. Now when this data gets dirty, copy-on-write happens and now
we have a memory chunk, not used by anyone, wasted.
May be we need to have normal PerlModule, which loads into the base
interpretor and have a second directive PerlLocalModule which allows to
load the module only in the parent of the tipool?
also after I finish to clean up the PerlModule and move onto PerlRequire:
- shouldn't PerlRequire be just an alias for PerlModule? since apparently
its implementation seem to be identical to PerlModule.
---------------------------------------------------------------------
( cvs @ apache.org is so slow :( )
Index: Apache-Test/lib/Apache/TestConfig.pm
===================================================================
RCS file: /home/cvs/modperl-2.0/Apache-Test/lib/Apache/TestConfig.pm,v
retrieving revision 1.10
diff -b -u -r1.10 TestConfig.pm
--- Apache-Test/lib/Apache/TestConfig.pm 2001/04/20 16:46:50
1.10
+++ Apache-Test/lib/Apache/TestConfig.pm 2001/07/09 16:44:00
@@ -718,3 +718,6 @@
<Location /server-status>
SetHandler server-status
</Location>
+
+PerlModule CGI File::Find Template
+
Index: src/modules/perl/mod_perl.c
===================================================================
RCS file: /home/cvs/modperl-2.0/src/modules/perl/mod_perl.c,v
retrieving revision 1.58
diff -b -u -r1.58 mod_perl.c
--- src/modules/perl/mod_perl.c 2001/05/14 03:34:34 1.58
+++ src/modules/perl/mod_perl.c 2001/07/09 16:44:54
@@ -28,8 +28,8 @@
{
MP_dSCFG(s);
PerlInterpreter *perl;
- int status;
- char **argv;
+ int status, i;
+ char **argv, **entries;
int argc;
#ifndef USE_ITHREADS
modperl_cleanup_data_t *cdata;
@@ -80,6 +80,14 @@
modperl_shutdown, apr_pool_cleanup_null);
#endif
+ {
+ dTHXa(perl);
+ entries = (char **)scfg->PerlModule->elts;
+ for(i = 0; i < scfg->PerlModule->nelts; i++)
+ if (modperl_require_module(aTHX_ entries[i], TRUE) == FALSE)
+ exit(1);
+ }
+
return perl;
}
@@ -322,6 +330,7 @@
static const command_rec modperl_cmds[] = {
MP_CMD_SRV_ITERATE("PerlSwitches", switches, "Perl Switches"),
+ MP_CMD_SRV_ITERATE("PerlModule", modules, "PerlModule"),
MP_CMD_DIR_ITERATE("PerlOptions", options, "Perl Options"),
#ifdef MP_TRACE
MP_CMD_SRV_TAKE1("PerlTrace", trace, "Trace level"),
Index: src/modules/perl/modperl_cmd.c
===================================================================
RCS file: /home/cvs/modperl-2.0/src/modules/perl/modperl_cmd.c,v
retrieving revision 1.4
diff -b -u -r1.4 modperl_cmd.c
--- src/modules/perl/modperl_cmd.c 2001/04/06 02:18:15 1.4
+++ src/modules/perl/modperl_cmd.c 2001/07/09 16:44:55
@@ -39,9 +39,19 @@
MP_CMD_SRV_DECLARE(switches)
{
MP_dSCFG(parms->server);
+ MP_TRACE_d(MP_FUNC, "%s\n", arg);
modperl_config_srv_argv_push(arg);
return NULL;
}
+
+MP_CMD_SRV_DECLARE(modules)
+{
+ MP_dSCFG(parms->server);
+ *(const char **)apr_array_push(scfg->PerlModule) = arg;
+ MP_TRACE_d(MP_FUNC, "%s\n", arg);
+ return NULL;
+}
+
MP_CMD_SRV_DECLARE(options)
{
Index: src/modules/perl/modperl_cmd.h
===================================================================
RCS file: /home/cvs/modperl-2.0/src/modules/perl/modperl_cmd.h,v
retrieving revision 1.4
diff -b -u -r1.4 modperl_cmd.h
--- src/modules/perl/modperl_cmd.h 2001/04/06 02:18:15 1.4
+++ src/modules/perl/modperl_cmd.h 2001/07/09 16:44:56
@@ -10,6 +10,7 @@
void *dummy, const char *arg)
MP_CMD_SRV_DECLARE(trace);
MP_CMD_SRV_DECLARE(switches);
+MP_CMD_SRV_DECLARE(modules);
MP_CMD_SRV_DECLARE(options);
#ifdef USE_ITHREADS
Index: src/modules/perl/modperl_config.c
===================================================================
RCS file: /home/cvs/modperl-2.0/src/modules/perl/modperl_config.c,v
retrieving revision 1.32
diff -b -u -r1.32 modperl_config.c
--- src/modules/perl/modperl_config.c 2001/05/08 21:08:26 1.32
+++ src/modules/perl/modperl_config.c 2001/07/09 16:44:58
@@ -71,6 +71,8 @@
MpSrvENABLED_On(scfg); /* mod_perl enabled by default */
MpSrvHOOKS_ALL_On(scfg); /* all hooks enabled by default */
+ scfg->PerlModule = apr_array_make(p, 2, sizeof(char *));
+
scfg->argv = apr_array_make(p, 2, sizeof(char *));
modperl_config_srv_argv_push((char *)ap_server_argv0);
_____________________________________________________________________
Stas Bekman JAm_pH -- Just Another mod_perl Hacker
http://stason.org/ mod_perl Guide http://perl.apache.org/guide
mailto:[EMAIL PROTECTED] http://apachetoday.com http://eXtropia.com/
http://singlesheaven.com http://perl.apache.org http://perlmonth.com/
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]