[svn:mod_parrot] r587 - in mod_parrot/trunk: include lib lib/ModParrot/Apache src
[email protected] Sat, 10 Jan 2009 11:11:10 -0800 (PST)
| Newsgroups | perl.cvs.mod_parrot |
|---|---|
| Message-ID | <[email protected]> |
Author: jhorwitz
Date: Sat Jan 10 11:11:09 2009
New Revision: 587
Modified:
mod_parrot/trunk/include/modparrot_config.h
mod_parrot/trunk/lib/ModParrot/Apache/Module.pir
mod_parrot/trunk/lib/mod_parrot.pir
mod_parrot/trunk/src/mod_parrot.c
mod_parrot/trunk/src/modparrot_config.c
Log:
determine path to mod_parrot.so so dlopen will work properly in freebsd
Modified: mod_parrot/trunk/include/modparrot_config.h
==============================================================================
--- mod_parrot/trunk/include/modparrot_config.h (original)
+++ mod_parrot/trunk/include/modparrot_config.h Sat Jan 10 11:11:09 2009
@@ -121,6 +121,7 @@
char *include_path;
char *dynext_path;
char *lib_path;
+ char *so_path;
apr_array_header_t *preload;
apr_array_header_t *module_array;
apr_hash_t *module_hash;
Modified: mod_parrot/trunk/lib/ModParrot/Apache/Module.pir
==============================================================================
--- mod_parrot/trunk/lib/ModParrot/Apache/Module.pir (original)
+++ mod_parrot/trunk/lib/ModParrot/Apache/Module.pir Sat Jan 10 11:11:09 2009
@@ -31,16 +31,6 @@
.local pmc func
.local pmc lib
- null $S0
- loadlib lib, $S0
-
- dlfunc func, lib, "mpnci_add_apache_module", "pJttPP"
- set_root_global [ 'ModParrot'; 'NCI' ], "add_apache_module", func
-
- dlfunc func, lib, "mpnci_get_module_config", "PJtpi"
- set_root_global [ 'ModParrot'; 'NCI' ], "get_module_config", func
-
- # XXX do we even use this?
newclass module_class, [ 'ModParrot'; 'Apache'; 'Module' ]
addattribute module_class, 'module'
.end
Modified: mod_parrot/trunk/lib/mod_parrot.pir
==============================================================================
--- mod_parrot/trunk/lib/mod_parrot.pir (original)
+++ mod_parrot/trunk/lib/mod_parrot.pir Sat Jan 10 11:11:09 2009
@@ -24,6 +24,10 @@
.local pmc lib
null $S0
+ $P0 = get_hll_global ['_modparrot'], '__module_path'
+ if null $P0 goto do_loadlib
+ $S0 = $P0
+ do_loadlib:
loadlib lib, $S0
# loadlib here instead of as a pragma in case we set the dynext path
@@ -110,6 +114,12 @@
dlfunc func, lib, "mpnci_register_pool_cleanup", "vJpPP"
set_root_global [ 'ModParrot'; 'NCI' ], "register_pool_cleanup", func
+ dlfunc func, lib, "mpnci_add_apache_module", "pJttPP"
+ set_root_global [ 'ModParrot'; 'NCI' ], "add_apache_module", func
+
+ dlfunc func, lib, "mpnci_get_module_config", "PJtpi"
+ set_root_global [ 'ModParrot'; 'NCI' ], "get_module_config", func
+
# load required libraries
load_bytecode 'Protoobject.pbc'
load_bytecode 'ModParrot/Interpreter.pbc'
Modified: mod_parrot/trunk/src/mod_parrot.c
==============================================================================
--- mod_parrot/trunk/src/mod_parrot.c (original)
+++ mod_parrot/trunk/src/mod_parrot.c Sat Jan 10 11:11:09 2009
@@ -100,6 +100,21 @@
Parrot_set_trace(interp, (cfg->option_flags & MP_OPT_TRACE_INIT) ?
cfg->trace_flags : 0);
+ /* if appropriate, set path to mod_parrot module (for some dlopens) */
+ if (cfg->so_path) {
+ Parrot_PMC path;
+ int typenum = Parrot_PMC_typenum(interp, "String");
+ path = Parrot_PMC_new(interp, typenum);
+ Parrot_register_pmc(interp, path);
+ Parrot_PMC_set_cstring(interp, path, cfg->so_path);
+ Parrot_store_global_s(
+ interp,
+ string_from_literal(interp, "_modparrot"),
+ string_from_literal(interp, "__module_path"),
+ path
+ );
+ }
+
/* load the init code */
modparrot_load_bytecode(interp,
cfg->init_path ? cfg->init_path : MODPARROT_DEFAULT_INIT);
Modified: mod_parrot/trunk/src/modparrot_config.c
==============================================================================
--- mod_parrot/trunk/src/modparrot_config.c (original)
+++ mod_parrot/trunk/src/modparrot_config.c Sat Jan 10 11:11:09 2009
@@ -29,6 +29,11 @@
#include "modparrot_config.h"
#include "modparrot_log.h"
+#if (__FreeBSD__)
+# include <dlfcn.h>
+# include "apr_dso.h"
+#endif /* (__FreeBSD__) */
+
#define GET_SERVER_CONFIG(x) \
((modparrot_srv_config *)ap_get_module_config(\
x->server->module_config, &parrot_module))
@@ -82,6 +87,25 @@
cfg->handler_modules[i] = NULL;
}
+ /* unfortunately, some OS-specific stuff */
+#if (__FreeBSD__)
+ {
+ apr_os_dso_handle_t *osdso;
+ char origin[PATH_MAX];
+ apr_os_dso_handle_get((void *)&osdso,
+ parrot_module.dynamic_load_handle);
+ if (dlinfo(osdso, RTLD_DI_ORIGIN, &origin) != -1) {
+ /* we know it's a Unix variant, so we can assume '/' and .so */
+ char *path = apr_pstrcat(p, origin, "/", "mod_parrot.so", NULL);
+ cfg->so_path = path;
+ }
+ else {
+ cfg->so_path = NULL;
+ fprintf(stderr, "dlinfo: %s", dlerror());
+ }
+ }
+#endif /* (__FreeBSD__) */
+
/* destroy context pool on cleanup */
apr_pool_cleanup_register(p, s, modparrot_cleanup, apr_pool_cleanup_null);