From: Brian Pane Date: Sat, 24 Nov 2001 10:13:29 +0000 (+0000) Subject: optimization: short-circuit out of the mod_actions handler if there are no actions... X-Git-Tag: 2.0.29~23 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5998b7f194f5c4a2dc6ca081d0a967a05794614d;p=apache optimization: short-circuit out of the mod_actions handler if there are no actions defined in the config git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@92162 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/modules/mappers/mod_actions.c b/modules/mappers/mod_actions.c index 2eb411be34..ee176b6349 100644 --- a/modules/mappers/mod_actions.c +++ b/modules/mappers/mod_actions.c @@ -92,6 +92,9 @@ typedef struct { apr_table_t *action_types; /* Added with Action... */ const char *scripted[METHODS]; /* Added with Script... */ + int configured; /* True if Action or Script has been + * called at least once + */ } action_dir_config; module actions_module; @@ -121,6 +124,8 @@ static void *merge_action_dir_configs(apr_pool_t *p, void *basev, void *addv) new->scripted[i] = add->scripted[i] ? add->scripted[i] : base->scripted[i]; } + + new->configured = (base->configured || add->configured); return new; } @@ -129,6 +134,7 @@ static const char *add_action(cmd_parms *cmd, void *m_v, { action_dir_config *m = (action_dir_config *)m_v; apr_table_setn(m->action_types, type, script); + m->configured = 1; return NULL; } @@ -146,6 +152,7 @@ static const char *set_script(cmd_parms *cmd, void *m_v, else m->scripted[methnum] = script; + m->configured = 1; return NULL; } @@ -162,11 +169,14 @@ static int action_handler(request_rec *r) { action_dir_config *conf = (action_dir_config *) ap_get_module_config(r->per_dir_config, &actions_module); - const char *t, *action = r->handler ? r->handler : - ap_field_noparam(r->pool, r->content_type); + const char *t, *action; const char *script; int i; + if (!conf->configured) { + return DECLINED; + } + /* Note that this handler handles _all_ types, so handler is unchecked */ /* Set allowed stuff */ @@ -191,6 +201,8 @@ static int action_handler(request_rec *r) return DECLINED; /* Second, check for actions (which override the method scripts) */ + action = r->handler ? r->handler : + ap_field_noparam(r->pool, r->content_type); if ((t = apr_table_get(conf->action_types, action ? action : ap_default_type(r)))) { script = t;