[svn:mod_parrot] r425 - mod_parrot/branches/hll-modules/src
[email protected] Thu, 18 Sep 2008 19:40:06 -0700 (PDT)
| Newsgroups | perl.cvs.mod_parrot |
|---|---|
| Message-ID | <[email protected]> |
Author: jhorwitz
Date: Thu Sep 18 19:40:06 2008
New Revision: 425
Modified:
mod_parrot/branches/hll-modules/src/mod_parrot.c
Log:
convert non-response handlers to new model
Modified: mod_parrot/branches/hll-modules/src/mod_parrot.c
==============================================================================
--- mod_parrot/branches/hll-modules/src/mod_parrot.c (original)
+++ mod_parrot/branches/hll-modules/src/mod_parrot.c Thu Sep 18 19:40:06 2008
@@ -431,110 +431,155 @@
static int modparrot_process_connection_handler(conn_rec *c)
{
- modparrot_srv_config *cfg;
modparrot_context *ctxp;
- int handler_status;
- char *sub, *hll;
-
- /* get apache configs */
- cfg = ap_get_module_config(c->base_server->module_config, &parrot_module);
- /* politely decline request if not our handler */
- if (!(cfg->option_flags & MP_OPT_ENABLE) ||
- !cfg->process_connection_handler) {
- return DECLINED;
+ /* initialize context */
+ if (!(ctxp = init_ctx(c->base_server))) {
+ MPLOG_ERROR(c->base_server, "context initialization failed");
+ return HTTP_INTERNAL_SERVER_ERROR;
}
+ /* we're REALLY_FIRST, so reset the module index */
+ ctxp->module_index = -1;
+
+ /* clean up */
+ release_ctx(ctxp);
+
+ /* we only do setup */
+ return DECLINED;
+}
+
+static int modparrot_meta_process_connection_handler(conn_rec *c)
+{
+ modparrot_context *ctxp;
+ modparrot_srv_config *mpcfg;
+ module *modp;
+ modparrot_module_info *minfo;
+ Parrot_PMC sub;
+ int status;
+
/* initialize context */
if (!(ctxp = init_ctx(c->base_server))) {
MPLOG_ERROR(c->base_server, "context initialization failed");
return HTTP_INTERNAL_SERVER_ERROR;
}
+ /* get next module in line */
+ ctxp->module_index++;
+
+ /* decline if mod_parrot isn't enabled */
+ mpcfg = ap_get_module_config(c->base_server->module_config, &parrot_module);
+ if (!(mpcfg->option_flags & MP_OPT_ENABLE)) return DECLINED;
+
ctxp->c = c;
- /* call HLL handler */
- sub = "process_connection_handler";
- hll = cfg->process_connection_handler->hll ?
- cfg->process_connection_handler->hll : MODPARROT_DEFAULT_HLL;
-
- if (!modparrot_meta_handler(ctxp->interp, hll, sub,
- cfg->process_connection_handler->id, &handler_status)) {
- MPLOG_ERRORF(c->base_server, "no subroutine found for handler '%s'",
- cfg->process_connection_handler->id);
- release_ctx(ctxp);
- return HTTP_INTERNAL_SERVER_ERROR;
+ /* get HLL config */
+ modp = ((module **)mpcfg->module_array->elts)[ctxp->module_index];
+ minfo = (modparrot_module_info *)modp->dynamic_load_handle;
+ /* call meta handler */
+ if (!modparrot_call_meta_handler(ctxp->interp, minfo->namespace,
+ "process_connection_handler", &status)) {
+ MPLOG_ERRORF(c->base_server,
+ "no process_connection metahandler found for module '%s'",
+ modp->name);
+ status = HTTP_INTERNAL_SERVER_ERROR;
}
/* clean up */
release_ctx(ctxp);
/* tell apache we're done */
- return handler_status;
+ return status;
}
-/* XXX - how do we notify apache of failures with a void return??? */
static void modparrot_child_init_handler(apr_pool_t *p, server_rec *s)
{
- modparrot_srv_config *cfg;
modparrot_context *ctxp;
- int handler_status;
- char *sub, *hll;
-
- /* get apache configs */
- cfg = ap_get_module_config(s->module_config, &parrot_module);
- /* politely decline request if not our handler */
- if (!(cfg->option_flags & MP_OPT_ENABLE) || !cfg->child_init_handler) {
+ /* initialize context */
+ if (!(ctxp = init_ctx(s))) {
+ MPLOG_ERROR(s, "context initialization failed");
return;
}
+ /* we're REALLY_FIRST, so reset the module index */
+ ctxp->module_index = -1;
+
+ /* clean up */
+ release_ctx(ctxp);
+}
+
+/* XXX - how do we notify apache of failures with a void return??? */
+static void modparrot_meta_child_init_handler(apr_pool_t *p, server_rec *s)
+{
+ modparrot_context *ctxp;
+ modparrot_srv_config *mpcfg;
+ module *modp;
+ modparrot_module_info *minfo;
+ Parrot_PMC sub;
+ int status;
+
/* initialize context */
if (!(ctxp = init_ctx(s))) {
MPLOG_ERROR(s, "context initialization failed");
return;
}
+ /* get next module in line */
+ ctxp->module_index++;
+
+ /* decline if mod_parrot isn't enabled */
+ mpcfg = ap_get_module_config(s->module_config, &parrot_module);
+ if (!(mpcfg->option_flags & MP_OPT_ENABLE)) return;
+
ctxp->pchild = p;
ctxp->s = s;
- /* call HLL handler */
- sub = "child_init_handler";
- hll = cfg->child_init_handler->hll ?
- cfg->child_init_handler->hll : MODPARROT_DEFAULT_HLL;
-
- if (!modparrot_meta_handler(ctxp->interp, hll, sub,
- cfg->child_init_handler->id, &handler_status)) {
- MPLOG_ERRORF(s, "no subroutine found for handler '%s'",
- cfg->child_init_handler->id);
+ /* get HLL config */
+ modp = ((module **)mpcfg->module_array->elts)[ctxp->module_index];
+ minfo = (modparrot_module_info *)modp->dynamic_load_handle;
+ /* call meta handler */
+ if (!modparrot_call_meta_handler(ctxp->interp, minfo->namespace,
+ "child_init_handler", &status)) {
+ MPLOG_ERRORF(s, "no child_init metahandler found for module '%s'",
+ modp->name);
return;
}
/* clean up */
release_ctx(ctxp);
-
- /* tell apache we're done */
- return;
}
static int modparrot_post_config_handler(apr_pool_t *pconf, apr_pool_t *plog,
apr_pool_t *ptemp, server_rec *s)
{
- modparrot_srv_config *cfg;
modparrot_context *ctxp;
- int handler_status;
- char *sub, *hll;
- /* add our info to apache's version string */
- ap_add_version_component(pconf, "mod_parrot/" MODPARROT_VERSION);
+ /* initialize context */
+ if (!(ctxp = init_ctx(s))) {
+ MPLOG_ERROR(s, "context initialization failed");
+ return HTTP_INTERNAL_SERVER_ERROR;
+ }
- /* get apache configs */
- cfg = ap_get_module_config(s->module_config, &parrot_module);
+ /* we're REALLY_FIRST, so reset the module index */
+ ctxp->module_index = -1;
- /* if not our handler, return OK (post_config must return OK) */
- if (!(cfg->option_flags & MP_OPT_ENABLE) || !cfg->post_config_handler) {
- return OK;
- }
+ /* clean up */
+ release_ctx(ctxp);
+
+ /* we only do setup */
+ return DECLINED;
+}
+
+static int modparrot_meta_post_config_handler(apr_pool_t *pconf,
+ apr_pool_t *plog, apr_pool_t *ptemp, server_rec *s)
+{
+ modparrot_context *ctxp;
+ modparrot_srv_config *mpcfg;
+ module *modp;
+ modparrot_module_info *minfo;
+ Parrot_PMC sub;
+ int status;
/* initialize context */
if (!(ctxp = init_ctx(s))) {
@@ -542,56 +587,68 @@
return HTTP_INTERNAL_SERVER_ERROR;
}
+ /* get next module in line */
+ ctxp->module_index++;
+
+ /* decline if mod_parrot isn't enabled */
+ mpcfg = ap_get_module_config(s->module_config, &parrot_module);
+ if (!(mpcfg->option_flags & MP_OPT_ENABLE)) return DECLINED;
+
ctxp->pconf = pconf;
ctxp->plog = plog;
ctxp->ptemp = ptemp;
ctxp->s = s;
- /* call HLL handler */
- sub = "post_config_handler";
- hll = cfg->post_config_handler->hll ?
- cfg->post_config_handler->hll : MODPARROT_DEFAULT_HLL;
-
- if (!modparrot_meta_handler(ctxp->interp, hll, sub,
- cfg->post_config_handler->id, &handler_status)) {
- MPLOG_ERRORF(s, "no subroutine found for handler '%s'",
- cfg->post_config_handler->id);
- release_ctx(ctxp);
- return HTTP_INTERNAL_SERVER_ERROR;
+ /* get HLL config */
+ modp = ((module **)mpcfg->module_array->elts)[ctxp->module_index];
+ minfo = (modparrot_module_info *)modp->dynamic_load_handle;
+ /* call meta handler */
+ if (!modparrot_call_meta_handler(ctxp->interp, minfo->namespace,
+ "post_config_handler", &status)) {
+ MPLOG_ERRORF(s, "no post_config metahandler found for module '%s'",
+ modp->name);
+ status = HTTP_INTERNAL_SERVER_ERROR;
}
/* clean up */
release_ctx(ctxp);
/* tell apache we're done */
- return handler_status;
+ return status;
}
static int modparrot_open_logs_handler(apr_pool_t *pconf, apr_pool_t *plog,
apr_pool_t *ptemp, server_rec *s)
{
- modparrot_srv_config *cfg;
modparrot_context *ctxp;
- int handler_status;
- char *sub, *hll;
+ modparrot_srv_config *mpcfg;
+ Parrot_Interp parent_interp;
server_rec *vs;
- Parrot_Interp parent_interp = NULL;
+
+ /* initialize context */
+ if (!(ctxp = init_ctx(s))) {
+ MPLOG_ERROR(s, "context initialization failed");
+ return HTTP_INTERNAL_SERVER_ERROR;
+ }
+
+ /* we're REALLY_FIRST, so reset the module index */
+ ctxp->module_index = -1;
/* get apache configs */
- cfg = ap_get_module_config(s->module_config, &parrot_module);
+ mpcfg = ap_get_module_config(s->module_config, &parrot_module);
- if (cfg->option_flags & MP_OPT_ENABLE) {
+ if (mpcfg->option_flags & MP_OPT_ENABLE) {
if (!(ctxp = modparrot_startup(pconf, s, NULL))) {
return HTTP_INTERNAL_SERVER_ERROR;
}
parent_interp = ctxp->interp;
/* load ParrotLoad files */
- modparrot_load_files(ctxp->interp, s, cfg->preload);
+ modparrot_load_files(ctxp->interp, s, mpcfg->preload);
/* if we weren't tracing the initialization phase, enable tracing now */
- if (!(cfg->option_flags & MP_OPT_TRACE_INIT)) {
- Parrot_set_trace(ctxp->interp, cfg->trace_flags);
+ if (!(mpcfg->option_flags & MP_OPT_TRACE_INIT)) {
+ Parrot_set_trace(ctxp->interp, mpcfg->trace_flags);
}
}
@@ -619,43 +676,66 @@
}
else {
if (vscfg->option_flags & MP_OPT_ENABLE) {
- vscfg->ctx_pool = cfg->ctx_pool;
+ vscfg->ctx_pool = mpcfg->ctx_pool;
}
else {
- MPLOG_ERROR(vs, "must use +Parent if mod_parrot is disabled in main server");
+ MPLOG_ERROR(vs,
+ "must use +Parent if mod_parrot is disabled in main server");
}
}
}
- /* if not our handler, return OK (open_logs must return OK) */
- if (!cfg->open_logs_handler) {
- release_ctx(ctxp);
- return OK;
+ /* clean up */
+ release_ctx(ctxp);
+
+ /* tell apache we're done -- open_logs handler must return OK */
+ return OK;
+}
+
+static int modparrot_meta_open_logs_handler(apr_pool_t *pconf,
+ apr_pool_t *plog, apr_pool_t *ptemp, server_rec *s)
+{
+ modparrot_context *ctxp;
+ modparrot_srv_config *mpcfg;
+ module *modp;
+ modparrot_module_info *minfo;
+ Parrot_PMC sub;
+ int status;
+
+ /* initialize context */
+ if (!(ctxp = init_ctx(s))) {
+ MPLOG_ERROR(s, "context initialization failed");
+ return HTTP_INTERNAL_SERVER_ERROR;
}
+ /* get next module in line */
+ ctxp->module_index++;
+
+ /* decline if mod_parrot isn't enabled -- but open_logs must return OK */
+ mpcfg = ap_get_module_config(s->module_config, &parrot_module);
+ if (!(mpcfg->option_flags & MP_OPT_ENABLE)) return OK;
+
ctxp->pconf = pconf;
ctxp->plog = plog;
ctxp->ptemp = ptemp;
ctxp->s = s;
- /* call HLL handler */
- sub = "open_logs_handler";
- hll = cfg->open_logs_handler->hll ?
- cfg->open_logs_handler->hll : MODPARROT_DEFAULT_HLL;
-
- if (!modparrot_meta_handler(ctxp->interp, hll, sub,
- cfg->open_logs_handler->id, &handler_status)) {
- MPLOG_ERRORF(s, "no subroutine found for handler '%s'",
- cfg->open_logs_handler->id);
- release_ctx(ctxp);
- return HTTP_INTERNAL_SERVER_ERROR;
+ /* get HLL config */
+ modp = ((module **)mpcfg->module_array->elts)[ctxp->module_index];
+ minfo = (modparrot_module_info *)modp->dynamic_load_handle;
+ /* call meta handler */
+ if (!modparrot_call_meta_handler(ctxp->interp, minfo->namespace,
+ "open_logs_handler", &status)) {
+ MPLOG_ERRORF(s, "no open_logs metahandler found for module '%s'",
+ modp->name);
+ status = HTTP_INTERNAL_SERVER_ERROR;
}
/* clean up */
release_ctx(ctxp);
/* tell apache we're done */
- return handler_status;
+ return status;
}
static int modparrot_cleanup_handler(request_rec *r)