]> granicus.if.org Git - apache/commitdiff
Make handlers use hooks.
authorBen Laurie <ben@apache.org>
Sun, 7 Jan 2001 19:55:59 +0000 (19:55 +0000)
committerBen Laurie <ben@apache.org>
Sun, 7 Jan 2001 19:55:59 +0000 (19:55 +0000)
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@87604 13f79535-47bb-0310-9956-ffa450edef68

24 files changed:
include/http_config.h
modules/aaa/mod_access.c
modules/aaa/mod_auth.c
modules/experimental/mod_generic_hook_export.c
modules/experimental/mod_generic_hook_import.c
modules/filters/mod_include.c
modules/generators/mod_asis.c
modules/generators/mod_autoindex.c
modules/generators/mod_cgi.c
modules/generators/mod_cgid.c
modules/http/http_core.c
modules/http/mod_mime.c
modules/loggers/mod_log_config.c
modules/mappers/mod_actions.c
modules/mappers/mod_alias.c
modules/mappers/mod_dir.c
modules/mappers/mod_imap.c
modules/mappers/mod_negotiation.c
modules/mappers/mod_userdir.c
modules/metadata/mod_env.c
modules/metadata/mod_setenvif.c
server/config.c
server/mpm/mpmt_pthread/mpmt_pthread.c
server/mpm/prefork/prefork.c

index a977776b0e98667211b6c27184790b4e314cbbbc..a515df31f0705c5f7c0876c8fe5f67aff08f8956 100644 (file)
@@ -317,20 +317,6 @@ struct cmd_parms_struct {
     const ap_directive_t *err_directive;
 };
 
-typedef struct handler_rec handler_rec;
-
-/** This structure records the existence of handlers in a module... */
-struct handler_rec {
-    /** The type of content this handler function will handle.  
-     *  MUST be all lower case 
-     */
-    const char *content_type;
-    /** The function to call when this context-type is requested. 
-     *  @deffunc int handler(request_rec *)
-     */
-    int (*handler) (request_rec *);
-};
-
 typedef struct module_struct module;
 /**
  * Module structures.  Just about everything is dispatched through
@@ -405,9 +391,6 @@ struct module_struct {
     /** A command_rec table that describes all of the directives this module
      * defines. */
     const command_rec *cmds;
-    /** A handler_rec table that describes all of the mime-types this module
-     *  will server responses for. */
-    const handler_rec *handlers;
 
     /** A hook to allow modules to hook other points in the request processing.
      *  In this function, modules should call the ap_hook_*() functions to
@@ -1008,6 +991,15 @@ AP_DECLARE_HOOK(void,open_logs,
  */
 AP_DECLARE_HOOK(void,child_init,(apr_pool_t *pchild, server_rec *s))
 
+/**
+ * Run the handler functions for each module
+ * @param handler The handler string (a MIME type or a handler)
+ * @param r The request_rec
+ * @deffunc void ap_run_handler(const char *handler,request_rec *r)
+ * @tip non-wildcard handlers should HOOK_MIDDLE, wildcard HOOK_LAST
+ */
+AP_DECLARE_HOOK(int,handler,(const char *handler,request_rec *r))
+
 #ifdef __cplusplus
 }
 #endif
index 35c9f4430aaa0cb6ce8361d24145a20145d70158..e7c8510b7096976bb6bac76ab6e3fa6bdf2b4417 100644 (file)
@@ -419,6 +419,5 @@ module AP_MODULE_DECLARE_DATA access_module =
     NULL,                      /* server config */
     NULL,                      /* merge server config */
     access_cmds,
-    NULL,                      /* handlers */
     register_hooks             /* register hooks */
 };
index e870955c1c26fdaf0af690a026451f4038be026d..4d6a4dbc31cfe4a31174bfc2565b85ee64f16f8b 100644 (file)
@@ -332,6 +332,5 @@ module AP_MODULE_DECLARE_DATA auth_module =
     NULL,                      /* server config */
     NULL,                      /* merge server config */
     auth_cmds,                 /* command apr_table_t */
-    NULL,                      /* handlers */
     register_hooks             /* register hooks */
 };
index e49637acf2218f642ece47bae26a19aba3934c0a..01d9c68369523f436f5c21bc70d8b1faf1ac59d1 100644 (file)
@@ -78,6 +78,5 @@ module generic_hook_export_module =
     NULL,
     NULL,
     NULL,
-    NULL,
     ExportRegisterHooks
 };
index a93226900634298f2c70dc6f690221428ce68e3d..74d573f27194b2993687a151f3504ad0c6893ca4 100644 (file)
@@ -79,6 +79,5 @@ module generic_hook_import_module=
     NULL,
     NULL,
     NULL,
-    NULL,
     ImportRegisterHooks
 };
index 92f7585b56cfaa5c4f7a22ed8e88d189c94a120a..ff00fedbf1a7a351379a2a7e16d048cc812b2cd7 100644 (file)
@@ -3079,6 +3079,5 @@ module AP_MODULE_DECLARE_DATA includes_module =
     NULL,                       /* server config */
     NULL,                       /* merge server config */
     includes_cmds,              /* command apr_table_t */
-    NULL,                       /* handlers */
     register_hooks             /* register hooks */
 };
index c9ed4c919710b79cfb24b0c3bc5c0b1497011d5a..5702a907bf844628c93df1e378401e74673cc75f 100644 (file)
 
 #define ASIS_MAGIC_TYPE "httpd/send-as-is"
 
-static int asis_handler(request_rec *r)
+static int asis_handler(const char *handler,request_rec *r)
 {
     apr_file_t *f = NULL;
     apr_status_t status;
     const char *location;
     apr_size_t nbytes;
 
+    if(strcmp(handler,ASIS_MAGIC_TYPE) && strcmp(handler,"send-as-is"))
+       return DECLINED;
+
     r->allowed |= (1 << M_GET);
     if (r->method_number != M_GET)
        return DECLINED;
@@ -121,12 +124,10 @@ static int asis_handler(request_rec *r)
     return OK;
 }
 
-static const handler_rec asis_handlers[] =
+static void register_hooks(void)
 {
-    {ASIS_MAGIC_TYPE, asis_handler},
-    {"send-as-is", asis_handler},
-    {NULL}
-};
+    ap_hook_handler(asis_handler,NULL,NULL,AP_HOOK_MIDDLE);
+}
 
 module AP_MODULE_DECLARE_DATA asis_module =
 {
@@ -136,6 +137,5 @@ module AP_MODULE_DECLARE_DATA asis_module =
     NULL,                      /* create per-server config structure */
     NULL,                      /* merge per-server config structures */
     NULL,                      /* command apr_table_t */
-    asis_handlers,             /* handlers */
-    NULL                       /* register hooks */
+    register_hooks             /* register hooks */
 };
index af4094840b731d9163e895631d7c9349206da93d..79891d3d8fd0b1a00f7db11372ef238d9ac2496f 100644 (file)
@@ -1660,10 +1660,15 @@ static int index_directory(request_rec *r,
 
 /* The formal handler... */
 
-static int handle_autoindex(request_rec *r)
+static int handle_autoindex(const char *handler,request_rec *r)
 {
     autoindex_config_rec *d;
-    int allow_opts = ap_allow_options(r);
+    int allow_opts;
+
+    if(strcmp(handler,DIR_MAGIC_TYPE))
+       return DECLINED;
+
+    allow_opts = ap_allow_options(r);
 
     d = (autoindex_config_rec *) ap_get_module_config(r->per_dir_config,
                                                      &autoindex_module);
@@ -1693,12 +1698,10 @@ static int handle_autoindex(request_rec *r)
     }
 }
 
-
-static const handler_rec autoindex_handlers[] =
+static void register_hooks(void)
 {
-    {DIR_MAGIC_TYPE, handle_autoindex},
-    {NULL}
-};
+    ap_hook_handler(handle_autoindex,NULL,NULL,AP_HOOK_MIDDLE);
+}
 
 module AP_MODULE_DECLARE_DATA autoindex_module =
 {
@@ -1708,6 +1711,5 @@ module AP_MODULE_DECLARE_DATA autoindex_module =
     NULL,                      /* server config */
     NULL,                      /* merge server config */
     autoindex_cmds,            /* command apr_table_t */
-    autoindex_handlers,                /* handlers */
-    NULL                       /* register hooks */
+    register_hooks             /* register hooks */
 };
index 6505256a9afcabb97c3481f9ed4998ad132783cb..b1193d6a398d2fc3b3266632761755d2406a83d3 100644 (file)
@@ -498,7 +498,7 @@ static apr_status_t build_command_line(const char **cmd, request_rec *r,
     return APR_SUCCESS;
 }
 
-static int cgi_handler(request_rec *r)
+static int cgi_handler(const char *handler, request_rec *r)
 {
     int retval, nph, dbpos = 0;
     const char *argv0;
@@ -514,6 +514,9 @@ static int cgi_handler(request_rec *r)
     cgi_server_conf *conf;
     apr_status_t rv;
 
+    if(strcmp(handler,CGI_MAGIC_TYPE) && strcmp(handler,"cgi-script"))
+       return DECLINED;
+
     p = r->main ? r->main->pool : r->pool;
 
     if (r->method_number == M_OPTIONS) {
@@ -717,12 +720,10 @@ static int cgi_handler(request_rec *r)
     return OK;                 /* NOT r->status, even if it has changed. */
 }
 
-static const handler_rec cgi_handlers[] =
+static void register_hooks(void)
 {
-    {CGI_MAGIC_TYPE, cgi_handler},
-    {"cgi-script", cgi_handler},
-    {NULL}
-};
+    ap_hook_handler(cgi_handler, NULL, NULL, AP_HOOK_MIDDLE);
+}
 
 module AP_MODULE_DECLARE_DATA cgi_module =
 {
@@ -732,6 +733,5 @@ module AP_MODULE_DECLARE_DATA cgi_module =
     create_cgi_config,         /* server config */
     merge_cgi_config,          /* merge server config */
     cgi_cmds,                  /* command apr_table_t */
-    cgi_handlers,              /* handlers */
-    NULL                       /* register hooks */
+    register_hooks             /* register hooks */
 };
index ef88ce0dd614645d1df18bd8e57c4170b95f01b0..24fcee7a905ff1c202476cf4049ccd410c2982cd 100644 (file)
@@ -730,22 +730,25 @@ static int log_script(request_rec *r, cgid_server_conf * conf, int ret,
  * 
  * Actual cgid handling... 
  */ 
-static int cgid_handler(request_rec *r) 
+static int cgid_handler(const char *handler, request_rec *r) 
 { 
     int retval, nph, dbpos = 0; 
     char *argv0, *dbuf = NULL; 
     ap_bucket_brigade *bb;
     ap_bucket *b;
     char argsbuffer[HUGE_STRING_LEN]; 
-    void *sconf = r->server->module_config; 
-    cgid_server_conf *conf = (cgid_server_conf *) ap_get_module_config(sconf, &cgid_module); 
-    int is_included = !strcmp(r->protocol, "INCLUDED"); 
+    void *sconf;
+    cgid_server_conf *conf;
+    int is_included;
     int sd;
     char **env; 
     struct sockaddr_un unix_addr;
     apr_file_t *tempsock = NULL;
     apr_size_t nbytes;
 
+    if(strcmp(handler,CGI_MAGIC_TYPE) && strcmp(handler,"cgi-script"))
+       return DECLINED;
+
     if (r->method_number == M_OPTIONS) { 
         /* 99 out of 100 cgid scripts, this is all they support */ 
         r->allowed |= (1 << M_GET); 
@@ -753,6 +756,10 @@ static int cgid_handler(request_rec *r)
         return DECLINED; 
     } 
 
+    sconf = r->server->module_config; 
+    conf = (cgid_server_conf *) ap_get_module_config(sconf, &cgid_module); 
+    is_included = !strcmp(r->protocol, "INCLUDED"); 
+
     if ((argv0 = strrchr(r->filename, '/')) != NULL)
         argv0++;
     else
@@ -924,16 +931,10 @@ static int cgid_handler(request_rec *r)
     return OK; /* NOT r->status, even if it has changed. */ 
 } 
 
-static const handler_rec cgid_handlers[] = 
-{ 
-    {CGI_MAGIC_TYPE, cgid_handler}, 
-    {"cgi-script", cgid_handler}, 
-    {NULL} 
-};
-
 static void register_hook(void)
 {
     ap_hook_post_config(cgid_init, NULL, NULL, AP_HOOK_MIDDLE);
+    ap_hook_handler(cgid_handler, NULL, NULL, AP_HOOK_MIDDLE);
 }
 
 module AP_MODULE_DECLARE_DATA cgid_module = { 
@@ -943,7 +944,6 @@ module AP_MODULE_DECLARE_DATA cgid_module = {
     create_cgid_config, /* server config */ 
     merge_cgid_config, /* merge server config */ 
     cgid_cmds, /* command table */ 
-    cgid_handlers, /* handlers */ 
     register_hook /* register_handlers */ 
 }; 
 
index be30d82f731d423ac88291f4763a78745ab34cd3..cca74c68ed779e17187c15cf24723361e6b85e0d 100644 (file)
@@ -2971,12 +2971,11 @@ AP_DECLARE_NONSTD(int) ap_core_translate(request_rec *r)
 
 static int do_nothing(request_rec *r) { return OK; }
 
-static int default_handler(request_rec *r)
+static int default_handler(const char *handler, request_rec *r)
 {
     ap_bucket_brigade *bb;
     ap_bucket *e;
-    core_dir_config *d =
-           (core_dir_config *)ap_get_module_config(r->per_dir_config, &core_module);
+    core_dir_config *d;
     int errstatus;
     apr_file_t *fd = NULL;
     apr_status_t status;
@@ -2987,8 +2986,22 @@ static int default_handler(request_rec *r)
      *     support fairly closely (unlike 1.3, we don't handle computing md5
      *     when the charset is translated).
      */
-    int bld_content_md5 = 
-        (d->content_md5 & 1) && r->output_filters->frec->ftype != AP_FTYPE_CONTENT;
+    int bld_content_md5;
+
+    /*
+     * The old way of doing handlers meant that this handler would
+     * match literally anything - this way will require handler to
+     * have a / in the middle, which probably captures the original
+     * intent, but may cause problems at first - Ben 7th Jan 01
+     */
+    if(strcmp(handler,"request-handler")
+       && ap_strcmp_match(handler,"*/*"))
+       return DECLINED;
+
+    d = (core_dir_config *)ap_get_module_config(r->per_dir_config,
+                                               &core_module);
+    bld_content_md5 = (d->content_md5 & 1)
+      && r->output_filters->frec->ftype != AP_FTYPE_CONTENT;
 
     ap_allow_methods(r, MERGE_ALLOW, "GET", "OPTIONS", "POST", NULL);
 
@@ -3488,12 +3501,6 @@ static apr_status_t core_output_filter(ap_filter_t *f, ap_bucket_brigade *b)
     return APR_SUCCESS;
 }
 
-static const handler_rec core_handlers[] = {
-{ "*/*", default_handler },
-{ "default-handler", default_handler },
-{ NULL, NULL }
-};
-
 static void core_pre_config(apr_pool_t *pconf, apr_pool_t *plog, apr_pool_t *ptemp)
 {
     ap_init_bucket_types(pconf);
@@ -3547,6 +3554,7 @@ static void register_hooks(void)
     ap_hook_http_method(core_method,NULL,NULL,AP_HOOK_REALLY_LAST);
     ap_hook_default_port(core_port,NULL,NULL,AP_HOOK_REALLY_LAST);
     ap_hook_open_logs(core_open_logs,NULL,NULL,AP_HOOK_MIDDLE);
+    ap_hook_handler(default_handler,NULL,NULL,AP_HOOK_REALLY_LAST);
     /* FIXME: I suspect we can eliminate the need for these - Ben */
     ap_hook_type_checker(do_nothing,NULL,NULL,AP_HOOK_REALLY_LAST);
     ap_hook_access_checker(do_nothing,NULL,NULL,AP_HOOK_REALLY_LAST);
@@ -3579,6 +3587,5 @@ AP_DECLARE_DATA module core_module = {
     create_core_server_config, /* create per-server config structure */
     merge_core_server_configs, /* merge per-server config structures */
     core_cmds,                 /* command apr_table_t */
-    core_handlers,             /* handlers */
     register_hooks             /* register hooks */
 };
index 32ecc16b1ed07866620630b1944c952af16b11a8..6cbd5f7e0e7b93688630bcf6113bd8d14740e497 100644 (file)
@@ -854,6 +854,5 @@ module AP_MODULE_DECLARE_DATA mime_module = {
     NULL,                      /* create per-server config structure */
     NULL,                      /* merge per-server config structures */
     mime_cmds,                 /* command apr_table_t */
-    NULL,                      /* handlers */
     register_hooks             /* register hooks */
 };
index e4b036fda9037b770af88557199a8e4fde237fe6..a565010f30803ba3c7e1fea50c314b0b8db64b58 100644 (file)
@@ -1256,6 +1256,5 @@ module AP_MODULE_DECLARE_DATA config_log_module =
     make_config_log_state,      /* server config */
     merge_config_log_state,     /* merge server config */
     config_log_cmds,            /* command apr_table_t */
-    NULL,                       /* handlers */
     register_hooks              /* register hooks */
 };
index 25143acad0abca39781e9529b46e39f79ab95344..31639a223528dd225696c0936b3f3984b9836b28 100644 (file)
@@ -158,7 +158,7 @@ static const command_rec action_cmds[] =
     {NULL}
 };
 
-static int action_handler(request_rec *r)
+static int action_handler(const char *handler,request_rec *r)
 {
     action_dir_config *conf = (action_dir_config *)
         ap_get_module_config(r->per_dir_config, &action_module);
@@ -167,6 +167,8 @@ static int action_handler(request_rec *r)
     const char *script;
     int i;
 
+    /* Note that this handler handles _all_ types, so handler is unchecked */
+
     /* Set allowed stuff */
     for (i = 0; i < METHODS; ++i) {
         if (conf->scripted[i])
@@ -207,11 +209,10 @@ static int action_handler(request_rec *r)
     return OK;
 }
 
-static const handler_rec action_handlers[] =
+static void register_hooks(void)
 {
-    {"*/*", action_handler},
-    {NULL}
-};
+    ap_hook_handler(action_handler,NULL,NULL,AP_HOOK_LAST);
+}
 
 module action_module =
 {
@@ -221,6 +222,5 @@ module action_module =
     NULL,                      /* server config */
     NULL,                      /* merge server config */
     action_cmds,               /* command apr_table_t */
-    action_handlers,           /* handlers */
-    NULL                       /* register hooks */
+    register_hooks             /* register hooks */
 };
index 8ba9d2a9dc9b7620abc2208c64892447524053b3..40e5cf560bc1ead7153e15b3a7ebcd529c9c5e67 100644 (file)
@@ -436,6 +436,5 @@ module AP_MODULE_DECLARE_DATA alias_module =
     create_alias_config,       /* server config */
     merge_alias_config,                /* merge server configs */
     alias_cmds,                        /* command apr_table_t */
-    NULL,                      /* handlers */
     register_hooks             /* register hooks */
 };
index dec70e38083e7a450ea223426133f816f6fb5cc9..9391a919b7aaf3ee002d13eddff7193e4879fcb1 100644 (file)
@@ -116,16 +116,20 @@ static void *merge_dir_configs(apr_pool_t *p, void *basev, void *addv)
     return new;
 }
 
-static int handle_dir(request_rec *r)
+static int handle_dir(const char *handler,request_rec *r)
 {
-    dir_config_rec *d =
-    (dir_config_rec *) ap_get_module_config(r->per_dir_config,
-                                         &dir_module);
+    dir_config_rec *d;
     char *dummy_ptr[1];
     char **names_ptr;
     int num_names;
     int error_notfound = 0;
 
+    if(strcmp(handler,DIR_MAGIC_TYPE))
+       return DECLINED;
+
+    d = (dir_config_rec *) ap_get_module_config(r->per_dir_config,
+                                               &dir_module);
+
     if (r->uri[0] == '\0' || r->uri[strlen(r->uri) - 1] != '/') {
         char *ifile;
         if (r->args != NULL)
@@ -218,11 +222,12 @@ static int handle_dir(request_rec *r)
 }
 
 
-static const handler_rec dir_handlers[] =
+static void register_hooks(void)
 {
-    {DIR_MAGIC_TYPE, handle_dir},
-    {NULL}
-};
+    static const char * const aszSucc[]={ "mod_autoindex.c", NULL };
+
+    ap_hook_handler(handle_dir,NULL,aszSucc,AP_HOOK_MIDDLE);
+}
 
 module AP_MODULE_DECLARE_DATA dir_module = {
     STANDARD20_MODULE_STUFF,
@@ -231,6 +236,5 @@ module AP_MODULE_DECLARE_DATA dir_module = {
     NULL,                      /* create per-server config structure */
     NULL,                      /* merge per-server config structures */
     dir_cmds,                  /* command apr_table_t */
-    dir_handlers,              /* handlers */
-    NULL                       /* register hooks */
+    register_hooks             /* register hooks */
 };
index 7a1eb078ba7798a3931880e482019d46239a2d48..61544f82ee53d01f1bccc4e1ba921c896cb8c46d 100644 (file)
@@ -612,7 +612,7 @@ static void menu_footer(request_rec *r)
     ap_rputs("\n\n</body>\n</html>\n", r);         /* finish the menu */
 }
 
-static int imap_handler(request_rec *r)
+static int imap_handler(const char *handler,request_rec *r)
 {
     char input[MAX_STRING_LEN];
     char *directive;
@@ -632,18 +632,24 @@ static int imap_handler(request_rec *r)
     char *string_pos;
     int showmenu = 0;
 
-    imap_conf_rec *icr = ap_get_module_config(r->per_dir_config, &imap_module);
+    imap_conf_rec *icr;
 
-    char *imap_menu = icr->imap_menu ? icr->imap_menu : IMAP_MENU_DEFAULT;
-    char *imap_default = icr->imap_default
-                           ?  icr->imap_default : IMAP_DEFAULT_DEFAULT;
-    char *imap_base = icr->imap_base ? icr->imap_base : IMAP_BASE_DEFAULT;
+    char *imap_menu;
+    char *imap_default;
+    char *imap_base;
 
     configfile_t *imap; 
 
-    if (r->method_number != M_GET) {
+    if (r->method_number != M_GET || (strcmp(handler,IMAP_MAGIC_TYPE)
+                                     && strcmp(handler, "imap-file")))
        return DECLINED;
-    }
+
+    icr = ap_get_module_config(r->per_dir_config, &imap_module);
+
+    imap_menu = icr->imap_menu ? icr->imap_menu : IMAP_MENU_DEFAULT;
+    imap_default = icr->imap_default
+      ?  icr->imap_default : IMAP_DEFAULT_DEFAULT;
+    imap_base = icr->imap_base ? icr->imap_base : IMAP_BASE_DEFAULT;
 
     status = ap_pcfg_openfile(&imap, r->pool, r->filename);
 
@@ -907,13 +913,10 @@ menu_bail:
     return HTTP_INTERNAL_SERVER_ERROR;
 }
 
-
-static const handler_rec imap_handlers[] =
+static void register_hooks(void)
 {
-    {IMAP_MAGIC_TYPE, imap_handler},
-    {"imap-file", imap_handler},
-    {NULL}
-};
+    ap_hook_handler(imap_handler,NULL,NULL,AP_HOOK_MIDDLE);
+}
 
 module AP_MODULE_DECLARE_DATA imap_module =
 {
@@ -923,6 +926,5 @@ module AP_MODULE_DECLARE_DATA imap_module =
     NULL,                       /* server config */
     NULL,                       /* merge server config */
     imap_cmds,                  /* command apr_table_t */
-    imap_handlers,              /* handlers */
-    NULL                        /* register hooks */
+    register_hooks              /* register hooks */
 };
index 52a97168a8d3ea27f0932a7b4b0620b126e63126..2120d8d26a61d75f1d4b96c0edc0b88d1dd7241d 100644 (file)
@@ -2566,14 +2566,17 @@ static int do_negotiation(request_rec *r, negotiation_state *neg,
     return OK;
 }
 
-static int handle_map_file(request_rec *r)
+static int handle_map_file(const char *handler,request_rec *r)
 {
-    negotiation_state *neg = parse_accept_headers(r);
+    negotiation_state *neg;
     var_rec *best;
     int res;
-
     char *udir;
 
+    if(strcmp(handler,MAP_FILE_MAGIC_TYPE) && strcmp(handler,"type-map"))
+       return DECLINED;
+
+    neg = parse_accept_headers(r);
     if ((res = read_type_map(neg, r))) {
         return res;
     }
@@ -2742,17 +2745,11 @@ static int fix_encoding(request_rec *r)
     return DECLINED;
 }
 
-static const handler_rec negotiation_handlers[] =
-{
-    {MAP_FILE_MAGIC_TYPE, handle_map_file},
-    {"type-map", handle_map_file},
-    {NULL}
-};
-
 static void register_hooks(void)
 {
     ap_hook_fixups(fix_encoding,NULL,NULL,AP_HOOK_MIDDLE);
     ap_hook_type_checker(handle_multi,NULL,NULL,AP_HOOK_FIRST);
+    ap_hook_handler(handle_map_file,NULL,NULL,AP_HOOK_MIDDLE);
 }
 
 module AP_MODULE_DECLARE_DATA negotiation_module =
@@ -2763,6 +2760,5 @@ module AP_MODULE_DECLARE_DATA negotiation_module =
     NULL,                       /* server config */
     NULL,                       /* merge server config */
     negotiation_cmds,           /* command apr_table_t */
-    negotiation_handlers,       /* handlers */
     register_hooks              /* register hooks */
 };
index c173272075e603028af2e59b50bc98a334e8600e..e4eb99ac791e873a83d7cef981eb0d29268e2139 100644 (file)
@@ -401,6 +401,5 @@ module userdir_module = {
     create_userdir_config,      /* server config */
     NULL,                       /* merge server config */
     userdir_cmds,               /* command apr_table_t */
-    NULL,                       /* handlers */
     register_hooks              /* register hooks */
 };
index f89546af4af98cafd5b0cb9a54e0d630cae33bd4..732f6c82eb69d1657511a8ed1c5a9defbca0e802 100644 (file)
@@ -268,6 +268,5 @@ module AP_MODULE_DECLARE_DATA env_module =
     NULL,                       /* server config */
     NULL,                       /* merge server configs */
     env_module_cmds,            /* command apr_table_t */
-    NULL,                       /* handlers */
     register_hooks              /* register hooks */
 };
index f50d4f5af9ad374526703020be88a97de4c8c14b..c4c5fbb0a1bfaaf848f787210085dc6e241e8161 100644 (file)
@@ -466,6 +466,5 @@ module AP_MODULE_DECLARE_DATA setenvif_module =
     create_setenvif_config_svr, /* server config */
     merge_setenvif_config,      /* merge server configs */
     setenvif_module_cmds,       /* command apr_table_t */
-    NULL,                       /* handlers */
     register_hooks             /* register hooks */
 };
index c1dfb9061a7c28a68f5c7e9bed8e4efd06f2b655..93ccd1201bbba9917219b0000281943b6ca108b0 100644 (file)
@@ -110,11 +110,12 @@ AP_DECLARE_DATA apr_array_header_t *ap_server_config_defines;
 AP_DECLARE_DATA ap_directive_t *ap_conftree;
 
 AP_HOOK_STRUCT(
-           AP_HOOK_LINK(header_parser)
-           AP_HOOK_LINK(pre_config)
-           AP_HOOK_LINK(post_config)
-           AP_HOOK_LINK(open_logs)
-           AP_HOOK_LINK(child_init)
+              AP_HOOK_LINK(header_parser)
+              AP_HOOK_LINK(pre_config)
+              AP_HOOK_LINK(post_config)
+              AP_HOOK_LINK(open_logs)
+              AP_HOOK_LINK(child_init)
+              AP_HOOK_LINK(handler)
 )
 
 AP_IMPLEMENT_HOOK_RUN_ALL(int,header_parser,
@@ -131,6 +132,9 @@ AP_IMPLEMENT_HOOK_VOID(open_logs,
 AP_IMPLEMENT_HOOK_VOID(child_init,
                        (apr_pool_t *pchild, server_rec *s),(pchild,s))
 
+AP_IMPLEMENT_HOOK_RUN_FIRST(int,handler,(const char *handler,request_rec *r),
+                           (handler,r),DECLINED)
+
 /****************************************************************
  *
  * We begin with the functions which deal with the linked list
@@ -272,68 +276,8 @@ AP_CORE_DECLARE(void *) ap_create_per_dir_config(apr_pool_t *p)
     return create_empty_config(p);
 }
 
-/*
- * For speed/efficiency we generate a compact list of all the handlers
- * and wildcard handlers.  This means we won't have to scan the entire
- * module list looking for handlers... where we'll find a whole whack
- * of NULLs.
- */
-typedef struct {
-    handler_rec hr;
-    size_t len;
-} fast_handler_rec;
-
-static fast_handler_rec *handlers;
-static fast_handler_rec *wildhandlers;
-
-static void init_handlers(apr_pool_t *p)
-{
-    module *modp;
-    int nhandlers = 0;
-    int nwildhandlers = 0;
-    const handler_rec *handp;
-    fast_handler_rec *ph, *pw;
-    const char *starp;
-
-    for (modp = top_module; modp; modp = modp->next) {
-       if (!modp->handlers)
-           continue;
-       for (handp = modp->handlers; handp->content_type; ++handp) {
-           if (ap_strchr_c(handp->content_type, '*')) {
-                nwildhandlers ++;
-            } else {
-                nhandlers ++;
-            }
-        }
-    }
-    ph = handlers = apr_palloc(p, sizeof(*ph)*(nhandlers + 1));
-    pw = wildhandlers = apr_palloc(p, sizeof(*pw)*(nwildhandlers + 1));
-    for (modp = top_module; modp; modp = modp->next) {
-       if (!modp->handlers)
-           continue;
-       for (handp = modp->handlers; handp->content_type; ++handp) {
-           if ((starp = ap_strchr_c(handp->content_type, '*'))) {
-                pw->hr.content_type = handp->content_type;
-                pw->hr.handler = handp->handler;
-               pw->len = starp - handp->content_type;
-                pw ++;
-            } else {
-                ph->hr.content_type = handp->content_type;
-                ph->hr.handler = handp->handler;
-               ph->len = strlen(handp->content_type);
-                ph ++;
-            }
-        }
-    }
-    pw->hr.content_type = NULL;
-    pw->hr.handler = NULL;
-    ph->hr.content_type = NULL;
-    ph->hr.handler = NULL;
-}
-
 int ap_invoke_handler(request_rec *r)
 {
-    fast_handler_rec *handp;
     const char *handler;
     const char *p;
     size_t handler_len;
@@ -356,35 +300,13 @@ int ap_invoke_handler(request_rec *r)
        }
     }
 
-    /* Pass one --- direct matches */
-
-    for (handp = handlers; handp->hr.content_type; ++handp) {
-        if (handler_len == handp->len
-            && !strncmp(handler, handp->hr.content_type, handler_len)) {
-            result = (*handp->hr.handler) (r);
-
-            if (result != DECLINED)
-                return result;
-        }
-    }
-
-    /* Pass two --- wildcard matches */
-
-    for (handp = wildhandlers; handp->hr.content_type; ++handp) {
-        if (handler_len >= handp->len
-            && !strncmp(handler, handp->hr.content_type, handp->len)) {
-            result = (*handp->hr.handler) (r);
-
-            if (result != DECLINED)
-                return result;
-         }
-    }
+    result=ap_run_handler(handler,r);
 
-    if (result == HTTP_INTERNAL_SERVER_ERROR && r->handler && r->filename) {
+    if (result == DECLINED && r->handler && r->filename) {
         ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_WARNING, 0, r,
             "handler \"%s\" not found for: %s", r->handler, r->filename);
     }
-    return HTTP_INTERNAL_SERVER_ERROR;
+    return result == DECLINED ? HTTP_INTERNAL_SERVER_ERROR : result;
 }
 
 AP_DECLARE(int) ap_method_is_limited(cmd_parms *cmd, const char *method) {
@@ -1712,7 +1634,6 @@ AP_DECLARE(void) ap_run_rewrite_args(process_rec *process)
 AP_DECLARE(void) ap_post_config_hook(apr_pool_t *pconf, apr_pool_t *plog, apr_pool_t *ptemp, server_rec *s)
 {
     ap_run_post_config(pconf,plog,ptemp,s); 
-    init_handlers(pconf);
 }
 
 void ap_child_init_hook(apr_pool_t *pchild, server_rec *s)
index 56a6bec9a15cdbd6131c3d0eb17695ed9f92bd1e..131e68fb08655a356ab9b670b9ebb3c318c9c310 100644 (file)
@@ -1407,7 +1407,6 @@ module AP_MODULE_DECLARE_DATA mpm_mpmt_pthread_module = {
     NULL,                      /* create per-server config structure */
     NULL,                      /* merge per-server config structures */
     mpmt_pthread_cmds,         /* command apr_table_t */
-    NULL,                      /* handlers */
     mpmt_pthread_hooks         /* register_hooks */
 };
 
index 77b217b3d9193a8a16feabfae3cab34377a99064..85b327e980b1ade1041526911ad90a1683e772ea 100644 (file)
@@ -1543,7 +1543,6 @@ static void prefork_pre_config(apr_pool_t *p, apr_pool_t *plog, apr_pool_t *ptem
     static int restart_num = 0;
     int no_detach = 0;
 
-    one_process = !!getenv("ONE_PROCESS");
     no_detach = !!getenv("NO_DETACH");
 
     /* sigh, want this only the second time around */
@@ -1578,7 +1577,7 @@ static void prefork_hooks(void)
 #ifdef AUX3
     (void) set42sig();
 #endif
-    /* TODO: set one_process properly */ one_process = 0;
+    one_process = !!getenv("ONE_PROCESS");
 
     ap_hook_pre_config(prefork_pre_config, NULL, NULL, AP_HOOK_MIDDLE);
 }
@@ -1878,6 +1877,5 @@ module AP_MODULE_DECLARE_DATA mpm_prefork_module = {
     NULL,                      /* create per-server config structure */
     NULL,                      /* merge per-server config structures */
     prefork_cmds,              /* command apr_table_t */
-    NULL,                      /* handlers */
     prefork_hooks,             /* register hooks */
 };