[svn:mod_parrot] r503 - in mod_parrot/trunk: include lib/ModParrot/HLL src
[email protected] Thu, 27 Nov 2008 10:59:25 -0800 (PST)
| Newsgroups | perl.cvs.mod_parrot |
|---|---|
| Message-ID | <[email protected]> |
Author: jhorwitz
Date: Thu Nov 27 10:59:25 2008
New Revision: 503
Modified:
mod_parrot/trunk/include/modparrot_config.h
mod_parrot/trunk/lib/ModParrot/HLL/pir.pir
mod_parrot/trunk/src/mod_parrot.c
Log:
refactor cleanup handlers to pave way for APR;Pool
create mod_parrot internal request cleanup handler
NOTE: HLL cleanup handlers are broken for now
Modified: mod_parrot/trunk/include/modparrot_config.h
==============================================================================
--- mod_parrot/trunk/include/modparrot_config.h (original)
+++ mod_parrot/trunk/include/modparrot_config.h Thu Nov 27 10:59:25 2008
@@ -77,7 +77,6 @@
MP_HOOK_TYPE,
MP_HOOK_FIXUP,
MP_HOOK_LOG,
- MP_HOOK_CLEANUP,
/* mark the end of the individual hooks */
MP_HOOK_LAST,
Modified: mod_parrot/trunk/lib/ModParrot/HLL/pir.pir
==============================================================================
--- mod_parrot/trunk/lib/ModParrot/HLL/pir.pir (original)
+++ mod_parrot/trunk/lib/ModParrot/HLL/pir.pir Thu Nov 27 10:59:25 2008
@@ -268,7 +268,7 @@
.param pmc args
$S0 = args[0]
- dircfg['cleanup_handler'] = $S0
+ # XXX waiting on APR;Pool implementation
.end
.sub load
Modified: mod_parrot/trunk/src/mod_parrot.c
==============================================================================
--- mod_parrot/trunk/src/mod_parrot.c (original)
+++ mod_parrot/trunk/src/mod_parrot.c Thu Nov 27 10:59:25 2008
@@ -65,6 +65,18 @@
apr_thread_mutex_t *conn_ctx_mutex;
#endif /* MPM_IS_THREADED */
+struct modparrot_cleanup_info {
+ int module_index; /* the HLL module that registered us */
+ Parrot_PMC callback; /* callback subroutine */
+ Parrot_PMC hll_data; /* a PMC to pass to the callback */
+ union { /* internal stuff for mod_parrot */
+ conn_rec *c;
+ request_rec *r;
+ } data;
+};
+typedef struct modparrot_cleanup_info modparrot_cleanup_info;
+
+
void modparrot_load_file(Parrot_Interp interp, server_rec *s, const char *file)
{
int ret;
@@ -310,65 +322,34 @@
return DECLINED;
}
-/* not a true handler since it has no hook */
-static int modparrot_meta_cleanup_handler(request_rec *r)
+/* XXX if we're not doing anything here, don't register it! */
+static apr_status_t modparrot_request_cleanup(void *data)
+{
+ return APR_SUCCESS;
+}
+
+static apr_status_t modparrot_meta_request_cleanup(void *data)
{
+ modparrot_cleanup_info *ci = (modparrot_cleanup_info *)data;
modparrot_context *ctxp;
- modparrot_srv_config *mpcfg;
- module *modp;
- modparrot_module_info *minfo;
- Parrot_PMC sub;
- int status, m;
+ int status;
/* initialize context */
- if (!(ctxp = init_ctx(r->server, r->connection))) {
- MPLOG_ERROR(r->server, "context initialization failed");
+ if (!(ctxp = init_ctx(ci->data.r->server, ci->data.r->connection))) {
+ MPLOG_ERROR(ci->data.r->server, "context initialization failed");
return HTTP_INTERNAL_SERVER_ERROR;
}
- /* get next module in line -- count backwards since cleanups are LIFO */
- m = ctxp->module_index--;
- assert(m >= 0);
-
- /* decline if mod_parrot isn't enabled */
- mpcfg = ap_get_module_config(r->server->module_config, &parrot_module);
- if (!(mpcfg->option_flags & MP_OPT_ENABLE)) return DECLINED;
+ /* set module index to the module that registered us */
+ ctxp->module_index = ci->module_index;
- ctxp->r = r;
+ /* call cleanup sub, passing HLL data from ci */
+ status = Parrot_call_sub_ret_int(ctxp->interp, ci->callback, "IP",
+ ci->hll_data);
- /* get HLL config */
- /* can't use NEXT_HANDLER_MODULE here since cleanup handlers are LIFO */
- modp = ((module **)mpcfg->module_array->elts)[mpcfg->handler_modules[MP_HOOK_CLEANUP]->elts[m]];
- minfo = (modparrot_module_info *)modp->dynamic_load_handle;
- /* check for an actual cleanup metahandler sub */
- /* XXX we shouldn't really be using get_sub_pmc here... */
- if (get_sub_pmc(ctxp->interp, minfo->namespace, "cleanup_handler")) {
- /* call meta handler */
- if (!modparrot_call_meta_handler(ctxp->interp, minfo->namespace,
- "cleanup_handler", &status)) {
- MPLOG_ERRORF(
- r->server,
- "no cleanup metahandler found for module '%s'",
- modp->name
- );
- status = HTTP_INTERNAL_SERVER_ERROR;
- }
- }
-
- /* clean up */
- release_ctx(ctxp);
-
- /* tell apache we're done */
return status;
}
-static apr_status_t modparrot_meta_request_cleanup(void *data)
-{
- request_rec *r = (request_rec *)data;
- modparrot_meta_cleanup_handler(r);
- return APR_SUCCESS;
-}
-
static apr_status_t modparrot_conn_cleanup(void *data)
{
conn_rec *c = (conn_rec *)data;
@@ -406,16 +387,16 @@
/* get next module in line */ \
if (!(mpcfg->option_flags & MP_OPT_ENABLE)) return DECLINED; \
modp = NEXT_HANDLER_MODULE(henum); \
- /* take this opportunity to register the mod_parrot cleanup handler \
+ /* take this opportunity to register the request cleanup handler \
* here, as we may not handle any other part of the request until \
- * then. \
+ * then. NOTE: this is mod_parrot internal only and NOT for HLLs. \
*/ \
if (register_cleanup) { \
+ /* XXX if callback doesn't do anything, don't register it! */ \
apr_pool_cleanup_register(r->pool, r, \
- modparrot_meta_request_cleanup, apr_pool_cleanup_null); \
+ modparrot_request_cleanup, apr_pool_cleanup_null); \
} \
ctxp->r = r; \
- /* XXX register cleanup handler here or in the meta handler? */ \
/* XXX does header_only check belong in the meta handler? */ \
if (r->header_only) { \
return OK; \