You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by be...@apache.org on 2001/01/07 20:55:59 UTC

cvs commit: httpd-2.0/server/mpm/prefork prefork.c

ben         01/01/07 11:55:59

  Modified:    include  http_config.h
               modules/aaa mod_access.c mod_auth.c
               modules/experimental mod_generic_hook_export.c
                        mod_generic_hook_import.c
               modules/filters mod_include.c
               modules/generators mod_asis.c mod_autoindex.c mod_cgi.c
                        mod_cgid.c
               modules/http http_core.c mod_mime.c
               modules/loggers mod_log_config.c
               modules/mappers mod_actions.c mod_alias.c mod_dir.c
                        mod_imap.c mod_negotiation.c mod_userdir.c
               modules/metadata mod_env.c mod_setenvif.c
               server   config.c
               server/mpm/mpmt_pthread mpmt_pthread.c
               server/mpm/prefork prefork.c
  Log:
  Make handlers use hooks.
  
  Revision  Changes    Path
  1.53      +9 -17     httpd-2.0/include/http_config.h
  
  Index: http_config.h
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/include/http_config.h,v
  retrieving revision 1.52
  retrieving revision 1.53
  diff -u -r1.52 -r1.53
  --- http_config.h	2000/12/19 17:05:12	1.52
  +++ http_config.h	2001/01/07 19:55:55	1.53
  @@ -317,20 +317,6 @@
       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 @@
       /** 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
  @@ -1007,6 +990,15 @@
    * @deffunc void ap_run_child_init(apr_pool_t *pchild, server_rec *s)
    */
   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
   }
  
  
  
  1.23      +0 -1      httpd-2.0/modules/aaa/mod_access.c
  
  Index: mod_access.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/modules/aaa/mod_access.c,v
  retrieving revision 1.22
  retrieving revision 1.23
  diff -u -r1.22 -r1.23
  --- mod_access.c	2000/12/14 18:47:22	1.22
  +++ mod_access.c	2001/01/07 19:55:55	1.23
  @@ -419,6 +419,5 @@
       NULL,			/* server config */
       NULL,			/* merge server config */
       access_cmds,
  -    NULL,			/* handlers */
       register_hooks		/* register hooks */
   };
  
  
  
  1.25      +0 -1      httpd-2.0/modules/aaa/mod_auth.c
  
  Index: mod_auth.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/modules/aaa/mod_auth.c,v
  retrieving revision 1.24
  retrieving revision 1.25
  diff -u -r1.24 -r1.25
  --- mod_auth.c	2000/10/16 06:05:04	1.24
  +++ mod_auth.c	2001/01/07 19:55:55	1.25
  @@ -332,6 +332,5 @@
       NULL,			/* server config */
       NULL,			/* merge server config */
       auth_cmds,			/* command apr_table_t */
  -    NULL,			/* handlers */
       register_hooks		/* register hooks */
   };
  
  
  
  1.2       +0 -1      httpd-2.0/modules/experimental/mod_generic_hook_export.c
  
  Index: mod_generic_hook_export.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/modules/experimental/mod_generic_hook_export.c,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- mod_generic_hook_export.c	2001/01/02 17:41:34	1.1
  +++ mod_generic_hook_export.c	2001/01/07 19:55:56	1.2
  @@ -78,6 +78,5 @@
       NULL,
       NULL,
       NULL,
  -    NULL,
       ExportRegisterHooks
   };
  
  
  
  1.2       +0 -1      httpd-2.0/modules/experimental/mod_generic_hook_import.c
  
  Index: mod_generic_hook_import.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/modules/experimental/mod_generic_hook_import.c,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- mod_generic_hook_import.c	2001/01/02 17:41:34	1.1
  +++ mod_generic_hook_import.c	2001/01/07 19:55:56	1.2
  @@ -79,6 +79,5 @@
       NULL,
       NULL,
       NULL,
  -    NULL,
       ImportRegisterHooks
   };
  
  
  
  1.84      +0 -1      httpd-2.0/modules/filters/mod_include.c
  
  Index: mod_include.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/modules/filters/mod_include.c,v
  retrieving revision 1.83
  retrieving revision 1.84
  diff -u -r1.83 -r1.84
  --- mod_include.c	2001/01/04 20:45:06	1.83
  +++ mod_include.c	2001/01/07 19:55:56	1.84
  @@ -3079,6 +3079,5 @@
       NULL,                       /* server config */
       NULL,                       /* merge server config */
       includes_cmds,              /* command apr_table_t */
  -    NULL,                       /* handlers */
       register_hooks		/* register hooks */
   };
  
  
  
  1.27      +8 -8      httpd-2.0/modules/generators/mod_asis.c
  
  Index: mod_asis.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/modules/generators/mod_asis.c,v
  retrieving revision 1.26
  retrieving revision 1.27
  diff -u -r1.26 -r1.27
  --- mod_asis.c	2000/10/16 06:05:04	1.26
  +++ mod_asis.c	2001/01/07 19:55:56	1.27
  @@ -68,13 +68,16 @@
   
   #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 @@
       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 @@
       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 */
   };
  
  
  
  1.50      +11 -9     httpd-2.0/modules/generators/mod_autoindex.c
  
  Index: mod_autoindex.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/modules/generators/mod_autoindex.c,v
  retrieving revision 1.49
  retrieving revision 1.50
  diff -u -r1.49 -r1.50
  --- mod_autoindex.c	2001/01/05 19:40:02	1.49
  +++ mod_autoindex.c	2001/01/07 19:55:56	1.50
  @@ -1660,11 +1660,16 @@
   
   /* 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 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 @@
       NULL,			/* server config */
       NULL,			/* merge server config */
       autoindex_cmds,		/* command apr_table_t */
  -    autoindex_handlers,		/* handlers */
  -    NULL			/* register hooks */
  +    register_hooks		/* register hooks */
   };
  
  
  
  1.76      +8 -8      httpd-2.0/modules/generators/mod_cgi.c
  
  Index: mod_cgi.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/modules/generators/mod_cgi.c,v
  retrieving revision 1.75
  retrieving revision 1.76
  diff -u -r1.75 -r1.76
  --- mod_cgi.c	2001/01/03 20:03:48	1.75
  +++ mod_cgi.c	2001/01/07 19:55:56	1.76
  @@ -498,7 +498,7 @@
       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 @@
       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 @@
       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 @@
       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 */
   };
  
  
  
  1.58      +12 -12    httpd-2.0/modules/generators/mod_cgid.c
  
  Index: mod_cgid.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/modules/generators/mod_cgid.c,v
  retrieving revision 1.57
  retrieving revision 1.58
  diff -u -r1.57 -r1.58
  --- mod_cgid.c	2001/01/03 20:03:48	1.57
  +++ mod_cgid.c	2001/01/07 19:55:56	1.58
  @@ -730,22 +730,25 @@
    * 
    * 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 @@
           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 @@
       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 @@
       create_cgid_config, /* server config */ 
       merge_cgid_config, /* merge server config */ 
       cgid_cmds, /* command table */ 
  -    cgid_handlers, /* handlers */ 
       register_hook /* register_handlers */ 
   }; 
   
  
  
  
  1.235     +19 -12    httpd-2.0/modules/http/http_core.c
  
  Index: http_core.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/modules/http/http_core.c,v
  retrieving revision 1.234
  retrieving revision 1.235
  diff -u -r1.234 -r1.235
  --- http_core.c	2001/01/05 20:44:41	1.234
  +++ http_core.c	2001/01/07 19:55:57	1.235
  @@ -2971,12 +2971,11 @@
   
   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,9 +2986,23 @@
        *     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);
   
       if ((errstatus = ap_discard_request_body(r)) != OK) {
  @@ -3488,12 +3501,6 @@
       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 @@
       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 @@
       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 */
   };
  
  
  
  1.32      +0 -1      httpd-2.0/modules/http/mod_mime.c
  
  Index: mod_mime.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/modules/http/mod_mime.c,v
  retrieving revision 1.31
  retrieving revision 1.32
  diff -u -r1.31 -r1.32
  --- mod_mime.c	2000/11/20 18:29:55	1.31
  +++ mod_mime.c	2001/01/07 19:55:57	1.32
  @@ -854,6 +854,5 @@
       NULL,			/* create per-server config structure */
       NULL,			/* merge per-server config structures */
       mime_cmds,			/* command apr_table_t */
  -    NULL,			/* handlers */
       register_hooks		/* register hooks */
   };
  
  
  
  1.43      +0 -1      httpd-2.0/modules/loggers/mod_log_config.c
  
  Index: mod_log_config.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/modules/loggers/mod_log_config.c,v
  retrieving revision 1.42
  retrieving revision 1.43
  diff -u -r1.42 -r1.43
  --- mod_log_config.c	2000/11/30 00:31:03	1.42
  +++ mod_log_config.c	2001/01/07 19:55:57	1.43
  @@ -1256,6 +1256,5 @@
       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 */
   };
  
  
  
  1.16      +7 -7      httpd-2.0/modules/mappers/mod_actions.c
  
  Index: mod_actions.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/modules/mappers/mod_actions.c,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- mod_actions.c	2000/11/29 19:39:17	1.15
  +++ mod_actions.c	2001/01/07 19:55:57	1.16
  @@ -158,7 +158,7 @@
       {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 @@
       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 @@
       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 @@
       NULL,			/* server config */
       NULL,			/* merge server config */
       action_cmds,		/* command apr_table_t */
  -    action_handlers,		/* handlers */
  -    NULL			/* register hooks */
  +    register_hooks		/* register hooks */
   };
  
  
  
  1.20      +0 -1      httpd-2.0/modules/mappers/mod_alias.c
  
  Index: mod_alias.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/modules/mappers/mod_alias.c,v
  retrieving revision 1.19
  retrieving revision 1.20
  diff -u -r1.19 -r1.20
  --- mod_alias.c	2000/11/10 01:12:10	1.19
  +++ mod_alias.c	2001/01/07 19:55:57	1.20
  @@ -436,6 +436,5 @@
       create_alias_config,	/* server config */
       merge_alias_config,		/* merge server configs */
       alias_cmds,			/* command apr_table_t */
  -    NULL,			/* handlers */
       register_hooks		/* register hooks */
   };
  
  
  
  1.23      +14 -10    httpd-2.0/modules/mappers/mod_dir.c
  
  Index: mod_dir.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/modules/mappers/mod_dir.c,v
  retrieving revision 1.22
  retrieving revision 1.23
  diff -u -r1.22 -r1.23
  --- mod_dir.c	2000/11/23 13:03:39	1.22
  +++ mod_dir.c	2001/01/07 19:55:57	1.23
  @@ -116,16 +116,20 @@
       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 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 @@
       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 */
   };
  
  
  
  1.24      +18 -16    httpd-2.0/modules/mappers/mod_imap.c
  
  Index: mod_imap.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/modules/mappers/mod_imap.c,v
  retrieving revision 1.23
  retrieving revision 1.24
  diff -u -r1.23 -r1.24
  --- mod_imap.c	2000/11/26 04:47:36	1.23
  +++ mod_imap.c	2001/01/07 19:55:57	1.24
  @@ -612,7 +612,7 @@
       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 @@
       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 @@
       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 @@
       NULL,                       /* server config */
       NULL,                       /* merge server config */
       imap_cmds,                  /* command apr_table_t */
  -    imap_handlers,              /* handlers */
  -    NULL                        /* register hooks */
  +    register_hooks              /* register hooks */
   };
  
  
  
  1.45      +7 -11     httpd-2.0/modules/mappers/mod_negotiation.c
  
  Index: mod_negotiation.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/modules/mappers/mod_negotiation.c,v
  retrieving revision 1.44
  retrieving revision 1.45
  diff -u -r1.44 -r1.45
  --- mod_negotiation.c	2001/01/05 19:40:02	1.44
  +++ mod_negotiation.c	2001/01/07 19:55:57	1.45
  @@ -2566,14 +2566,17 @@
       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 @@
       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 @@
       NULL,                       /* server config */
       NULL,                       /* merge server config */
       negotiation_cmds,           /* command apr_table_t */
  -    negotiation_handlers,       /* handlers */
       register_hooks              /* register hooks */
   };
  
  
  
  1.28      +0 -1      httpd-2.0/modules/mappers/mod_userdir.c
  
  Index: mod_userdir.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/modules/mappers/mod_userdir.c,v
  retrieving revision 1.27
  retrieving revision 1.28
  diff -u -r1.27 -r1.28
  --- mod_userdir.c	2000/11/13 03:18:18	1.27
  +++ mod_userdir.c	2001/01/07 19:55:58	1.28
  @@ -401,6 +401,5 @@
       create_userdir_config,      /* server config */
       NULL,                       /* merge server config */
       userdir_cmds,               /* command apr_table_t */
  -    NULL,                       /* handlers */
       register_hooks              /* register hooks */
   };
  
  
  
  1.17      +0 -1      httpd-2.0/modules/metadata/mod_env.c
  
  Index: mod_env.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/modules/metadata/mod_env.c,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- mod_env.c	2000/10/16 06:05:05	1.16
  +++ mod_env.c	2001/01/07 19:55:58	1.17
  @@ -268,6 +268,5 @@
       NULL,                       /* server config */
       NULL,                       /* merge server configs */
       env_module_cmds,            /* command apr_table_t */
  -    NULL,                       /* handlers */
       register_hooks              /* register hooks */
   };
  
  
  
  1.20      +0 -1      httpd-2.0/modules/metadata/mod_setenvif.c
  
  Index: mod_setenvif.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/modules/metadata/mod_setenvif.c,v
  retrieving revision 1.19
  retrieving revision 1.20
  diff -u -r1.19 -r1.20
  --- mod_setenvif.c	2000/10/16 06:05:07	1.19
  +++ mod_setenvif.c	2001/01/07 19:55:58	1.20
  @@ -466,6 +466,5 @@
       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 */
   };
  
  
  
  1.94      +12 -91    httpd-2.0/server/config.c
  
  Index: config.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/server/config.c,v
  retrieving revision 1.93
  retrieving revision 1.94
  diff -u -r1.93 -r1.94
  --- config.c	2001/01/05 20:44:43	1.93
  +++ config.c	2001/01/07 19:55:58	1.94
  @@ -110,11 +110,12 @@
   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(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 @@
       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;
  @@ -355,36 +299,14 @@
   	    handler_len = strlen(handler);
   	}
       }
  -
  -    /* 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_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)
  
  
  
  1.129     +0 -1      httpd-2.0/server/mpm/mpmt_pthread/mpmt_pthread.c
  
  Index: mpmt_pthread.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/server/mpm/mpmt_pthread/mpmt_pthread.c,v
  retrieving revision 1.128
  retrieving revision 1.129
  diff -u -r1.128 -r1.129
  --- mpmt_pthread.c	2000/12/19 20:44:23	1.128
  +++ mpmt_pthread.c	2001/01/07 19:55:58	1.129
  @@ -1407,7 +1407,6 @@
       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 */
   };
   
  
  
  
  1.140     +1 -3      httpd-2.0/server/mpm/prefork/prefork.c
  
  Index: prefork.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/server/mpm/prefork/prefork.c,v
  retrieving revision 1.139
  retrieving revision 1.140
  diff -u -r1.139 -r1.140
  --- prefork.c	2000/12/04 19:23:53	1.139
  +++ prefork.c	2001/01/07 19:55:59	1.140
  @@ -1543,7 +1543,6 @@
       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 @@
   #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 @@
       NULL,			/* create per-server config structure */
       NULL,			/* merge per-server config structures */
       prefork_cmds,		/* command apr_table_t */
  -    NULL,			/* handlers */
       prefork_hooks,		/* register hooks */
   };
  
  
  

Re: cvs commit: httpd-2.0/server/mpm/prefork prefork.c

Posted by Jeff Trawick <tr...@bellsouth.net>.
Since I obviously don't know the other questions to ask, I guess the
real question then is how to get mod_rewrite to stop segfaulting.

But maybe somebody has fixed mod_rewrite in the meantime.  I had to
remove it from my config to get work done.  I should add it back and
cross my fingers.

mod_info is another module which needs to be tweaked to keep from
segfaulting. 

Ben Laurie <be...@algroup.co.uk> writes:

> Jeff Trawick wrote:
> > 
> > ben@apache.org writes:
> > 
> > >   Log:
> > >   Make handlers use hooks.
> > 
> > What does r->handler get set to now?
> 
> Same as it ever did.
> 
> > mod_rewrite uses the string name of its (or mod_proxy's) handler in a
> > couple of places to set the handler.  What is the modern equivalent?
> 
> Same as it ever was.
> 
> > In mod_asis, you're checking that the handler name is "send-as-is,"
> > but how does the handler get set to that?
> 
> Same as it ever did. Mostly, I guess, through AddHandler or SetHandler.
> 
> Cheers,
> 
> Ben.
> 
> --
> http://www.apache-ssl.org/ben.html
> 
> "There is no limit to what a man can do or how far he can go if he
> doesn't mind who gets the credit." - Robert Woodruff
> 

-- 
Jeff Trawick | trawickj@bellsouth.net | PGP public key at web site:
       http://www.geocities.com/SiliconValley/Park/9289/
             Born in Roswell... married an alien...

Re: cvs commit: httpd-2.0/server/mpm/prefork prefork.c

Posted by Ben Laurie <be...@algroup.co.uk>.
Jeff Trawick wrote:
> 
> ben@apache.org writes:
> 
> >   Log:
> >   Make handlers use hooks.
> 
> What does r->handler get set to now?

Same as it ever did.

> mod_rewrite uses the string name of its (or mod_proxy's) handler in a
> couple of places to set the handler.  What is the modern equivalent?

Same as it ever was.

> In mod_asis, you're checking that the handler name is "send-as-is,"
> but how does the handler get set to that?

Same as it ever did. Mostly, I guess, through AddHandler or SetHandler.

Cheers,

Ben.

--
http://www.apache-ssl.org/ben.html

"There is no limit to what a man can do or how far he can go if he
doesn't mind who gets the credit." - Robert Woodruff

Re: cvs commit: httpd-2.0/server/mpm/prefork prefork.c

Posted by Jeff Trawick <tr...@bellsouth.net>.
ben@apache.org writes:

>   Log:
>   Make handlers use hooks.

What does r->handler get set to now?

mod_rewrite uses the string name of its (or mod_proxy's) handler in a
couple of places to set the handler.  What is the modern equivalent?

In mod_asis, you're checking that the handler name is "send-as-is,"
but how does the handler get set to that?

Thanks...
-- 
Jeff Trawick | trawickj@bellsouth.net | PGP public key at web site:
       http://www.geocities.com/SiliconValley/Park/9289/
             Born in Roswell... married an alien...

Re: cvs commit: httpd-2.0/server/mpm/prefork prefork.c

Posted by Greg Stein <gs...@lyra.org>.
On Sun, Jan 07, 2001 at 10:10:56PM +0000, Ben Laurie wrote:
>...
> I ran out of gas! I got a flat tire! I didn't have change for cab fare!
> I lost my tux at the cleaners! I locked my keys in the car! An old
> friend came in from out of town! Someone stole my car! There was an
> earthquake! A terrible flood! Locusts! IT WASN'T MY FAULT, I SWEAR TO
> GOD! (Bonus points if you recognise the quote :-)

"Oh, Jakey..."

Too easy :-)

Cheers,
-g

-- 
Greg Stein, http://www.lyra.org/

Re: cvs commit: httpd-2.0/server/mpm/prefork prefork.c

Posted by Ben Laurie <be...@algroup.co.uk>.
Greg Stein wrote:
> 
> On Sun, Jan 07, 2001 at 07:55:59PM -0000, ben@apache.org wrote:
> > ben         01/01/07 11:55:59
> >
> >   Modified:    include  http_config.h
> >                modules/aaa mod_access.c mod_auth.c
> >                modules/experimental mod_generic_hook_export.c
> >                         mod_generic_hook_import.c
> >                modules/filters mod_include.c
> >                modules/generators mod_asis.c mod_autoindex.c mod_cgi.c
> >                         mod_cgid.c
> >                modules/http http_core.c mod_mime.c
> >                modules/loggers mod_log_config.c
> >                modules/mappers mod_actions.c mod_alias.c mod_dir.c
> >                         mod_imap.c mod_negotiation.c mod_userdir.c
> >                modules/metadata mod_env.c mod_setenvif.c
> >                server   config.c
> >                server/mpm/mpmt_pthread mpmt_pthread.c
> >                server/mpm/prefork prefork.c
> >   Log:
> >   Make handlers use hooks.
> 
> This is incomplete. I see a handle_rec in mod_dav.c :-)

Correct. Well, nearly correct: it's a handler_rec :-)

> Did you just compile and fix the breakage, or did you do an actual search?

The former.

> The latter will be much more useful...

Indeed, but also much more work. I was running out of time. I had supper
to cook and children to put to bed. I've done that now, but I still
doubt whether I could complete the task before my bedtime. And then it
would be Monday, and I'd have to work (I'm writing a filesystem at the
moment, quite fun. Well, at least on Monday I am. On Tuesday I have to
go back to writing code to rip CDs, until I do my bit for Consume
[http://www.consume.net/] by going to meet guvmint types about it, then
on Wednesday... well, you get the picture).

I ran out of gas! I got a flat tire! I didn't have change for cab fare!
I lost my tux at the cleaners! I locked my keys in the car! An old
friend came in from out of town! Someone stole my car! There was an
earthquake! A terrible flood! Locusts! IT WASN'T MY FAULT, I SWEAR TO
GOD! (Bonus points if you recognise the quote :-)

Cheers,

Ben.

--
http://www.apache-ssl.org/ben.html

"There is no limit to what a man can do or how far he can go if he
doesn't mind who gets the credit." - Robert Woodruff

Re: cvs commit: httpd-2.0/server/mpm/prefork prefork.c

Posted by Greg Stein <gs...@lyra.org>.
On Sun, Jan 07, 2001 at 07:55:59PM -0000, ben@apache.org wrote:
> ben         01/01/07 11:55:59
> 
>   Modified:    include  http_config.h
>                modules/aaa mod_access.c mod_auth.c
>                modules/experimental mod_generic_hook_export.c
>                         mod_generic_hook_import.c
>                modules/filters mod_include.c
>                modules/generators mod_asis.c mod_autoindex.c mod_cgi.c
>                         mod_cgid.c
>                modules/http http_core.c mod_mime.c
>                modules/loggers mod_log_config.c
>                modules/mappers mod_actions.c mod_alias.c mod_dir.c
>                         mod_imap.c mod_negotiation.c mod_userdir.c
>                modules/metadata mod_env.c mod_setenvif.c
>                server   config.c
>                server/mpm/mpmt_pthread mpmt_pthread.c
>                server/mpm/prefork prefork.c
>   Log:
>   Make handlers use hooks.

This is incomplete. I see a handle_rec in mod_dav.c :-)

Did you just compile and fix the breakage, or did you do an actual search?
The latter will be much more useful...

Cheers,
-g

-- 
Greg Stein, http://www.lyra.org/

Re: cvs commit: httpd-2.0/server/mpm/prefork prefork.c

Posted by Ben Laurie <be...@algroup.co.uk>.
Greg Stein wrote:
> 
> On Mon, Jan 08, 2001 at 08:01:35AM -0500, Jeff Trawick wrote:
> > rbb@covalent.net writes:
> >...
> > > Can we change the strcmp to a memcmp, since we know that these are static
> > > strings?
> >
> > Is there a compiler which is known to generate worse code for strcmp()
> > than for memcmp() in this case?
> 
> It isn't so much the compiler, as just the actual semantics of the two
> functions. strcmp() copies until it reaches a null-term, which means it must
> be checking the bytes for a null-term. memcmp() just copies regardless.

I just said the same thing, but it seems not to have arrived yet.
Anyway, mere moments after hitting the send button I realised this ain't
true if one of the arguments is a fixed string - then you (and the
compiler) can use memcmp instead. Whether this means the code will be
the same for strcmp depends on whether memcmp is actually better than
strcmp.

Cheers,

Ben.

--
http://www.apache-ssl.org/ben.html

"There is no limit to what a man can do or how far he can go if he
doesn't mind who gets the credit." - Robert Woodruff

Re: cvs commit: httpd-2.0/server/mpm/prefork prefork.c

Posted by Jeff Trawick <tr...@bellsouth.net>.
Greg Stein <gs...@lyra.org> writes:

> On Mon, Jan 08, 2001 at 08:01:35AM -0500, Jeff Trawick wrote:
> > rbb@covalent.net writes:
> >...
> > > Can we change the strcmp to a memcmp, since we know that these are static
> > > strings?
> > 
> > Is there a compiler which is known to generate worse code for strcmp()
> > than for memcmp() in this case?
> 
> It isn't so much the compiler, as just the actual semantics of the two
> functions. strcmp() copies until it reaches a null-term, which means it must
> be checking the bytes for a null-term. memcmp() just copies
> regardless.

This argument does not apply to this case.  The string is known.
Compilers which generate in-line code for strxxx() and memxxx() will
certainly not generate code to search for the '\0'.

> Some CISC processors (e.g. x86, VAX) have special null-term operators, so
> they'll operate just as fast as plain operators. But for "all" processors, a
> memcmp/memcpy will be faster.

when the string is not known

Geez...
-- 
Jeff Trawick | trawickj@bellsouth.net | PGP public key at web site:
       http://www.geocities.com/SiliconValley/Park/9289/
             Born in Roswell... married an alien...

Re: cvs commit: httpd-2.0/server/mpm/prefork prefork.c

Posted by Greg Stein <gs...@lyra.org>.
On Mon, Jan 08, 2001 at 08:01:35AM -0500, Jeff Trawick wrote:
> rbb@covalent.net writes:
>...
> > Can we change the strcmp to a memcmp, since we know that these are static
> > strings?
> 
> Is there a compiler which is known to generate worse code for strcmp()
> than for memcmp() in this case?

It isn't so much the compiler, as just the actual semantics of the two
functions. strcmp() copies until it reaches a null-term, which means it must
be checking the bytes for a null-term. memcmp() just copies regardless.

Some CISC processors (e.g. x86, VAX) have special null-term operators, so
they'll operate just as fast as plain operators. But for "all" processors, a
memcmp/memcpy will be faster.

[ consider that memcmp/memcpy can actually work in multi-byte increments, up
  to the "end" where it drops back to byte-at-a-time for the last 0-3 bytes ]

Cheers,
-g

-- 
Greg Stein, http://www.lyra.org/

Re: cvs commit: httpd-2.0/server/mpm/prefork prefork.c

Posted by Ben Laurie <be...@algroup.co.uk>.
Jeff Trawick wrote:
> 
> rbb@covalent.net writes:
> 
> > >    #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;
> >
> > Can we change the strcmp to a memcmp, since we know that these are static
> > strings?
> 
> Is there a compiler which is known to generate worse code for strcmp()
> than for memcmp() in this case?
> 
> (I'm not saying there isn't; I just know that there are some which
> generate the same code.  Of course I'm speaking of compilers which
> generate inline code for various strxxx() and memxxx() "functions".)

??? How can they generate the same code? One runs until it hits NUL, the
other for a certain number of bytes!

Cheers,

Ben.

--
http://www.apache-ssl.org/ben.html

"There is no limit to what a man can do or how far he can go if he
doesn't mind who gets the credit." - Robert Woodruff

Re: cvs commit: httpd-2.0/server/mpm/prefork prefork.c

Posted by Jeff Trawick <tr...@bellsouth.net>.
rbb@covalent.net writes:

> > > Can we change the strcmp to a memcmp, since we know that these are static
> > > strings?
> > 
> > Is there a compiler which is known to generate worse code for strcmp()
> > than for memcmp() in this case?
> > 
> > (I'm not saying there isn't; I just know that there are some which
> > generate the same code.  Of course I'm speaking of compilers which
> > generate inline code for various strxxx() and memxxx() "functions".)
> 
> I don't really know, but memcmp can obviously generate fast code, so why
> take the chance?

no argument with that; I was just fishing for interesting info

-- 
Jeff Trawick | trawickj@bellsouth.net | PGP public key at web site:
       http://www.geocities.com/SiliconValley/Park/9289/
             Born in Roswell... married an alien...

Re: cvs commit: httpd-2.0/server/mpm/prefork prefork.c

Posted by rb...@covalent.net.
> > >   +    if(strcmp(handler,ASIS_MAGIC_TYPE) && strcmp(handler,"send-as-is"))
> > >   +	return DECLINED;
> > 
> > Can we change the strcmp to a memcmp, since we know that these are static
> > strings?
> 
> Is there a compiler which is known to generate worse code for strcmp()
> than for memcmp() in this case?
> 
> (I'm not saying there isn't; I just know that there are some which
> generate the same code.  Of course I'm speaking of compilers which
> generate inline code for various strxxx() and memxxx() "functions".)

I don't really know, but memcmp can obviously generate fast code, so why
take the chance?

Ryan

_______________________________________________________________________________
Ryan Bloom                        	rbb@apache.org
406 29th St.
San Francisco, CA 94131
-------------------------------------------------------------------------------


Re: cvs commit: httpd-2.0/server/mpm/prefork prefork.c

Posted by Jeff Trawick <tr...@bellsouth.net>.
rbb@covalent.net writes:

> >    #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;
> 
> Can we change the strcmp to a memcmp, since we know that these are static
> strings?

Is there a compiler which is known to generate worse code for strcmp()
than for memcmp() in this case?

(I'm not saying there isn't; I just know that there are some which
generate the same code.  Of course I'm speaking of compilers which
generate inline code for various strxxx() and memxxx() "functions".)

-- 
Jeff Trawick | trawickj@bellsouth.net | PGP public key at web site:
       http://www.geocities.com/SiliconValley/Park/9289/
             Born in Roswell... married an alien...

Re: cvs commit: httpd-2.0/server/mpm/prefork prefork.c

Posted by Greg Stein <gs...@lyra.org>.
On Sun, Jan 07, 2001 at 09:35:01PM +0000, Ben Laurie wrote:
> rbb@covalent.net wrote:
>...
> > > BTW, please can we make maintainer-mode have -Wall in it?
> > 
> > Last I checked, it did.
> 
> Apologies. I meant -Werror.

+0

-- 
Greg Stein, http://www.lyra.org/

Re: cvs commit: httpd-2.0/server/mpm/prefork prefork.c

Posted by Greg Stein <gs...@lyra.org>.
On Mon, Jan 08, 2001 at 08:30:26PM -0500, Jim Jagielski wrote:
> Ben Laurie wrote:
> > 
> > NO THEY CAN'T!!!! Like I keep saying, configure writes such crap C that
> > turning on -Werror causes it to get totally the wrong picture.
> > 
> > Actually, its just possible that "CFLAGS=-Werror ./configure
> > --with-maintainer-mode" would work, but that would be purely by luck.
> > I'd hate to rely on it. It certainly doens't if you switch on -Wall,
> > too.
> > 
> 
> Ahhhh... I see. The place to plop -Werror into CFLAGS is at
> the very *end* of the configure cycle, not at the start. Because
> doing so at the start effects all the test compilations that
> configure uses. Should be easy to do. Let me know.

That would be the trick. Go for it!

+1

-- 
Greg Stein, http://www.lyra.org/

Re: cvs commit: httpd-2.0/server/mpm/prefork prefork.c

Posted by Ben Laurie <be...@algroup.co.uk>.
Sascha Schumann wrote:
> 
> > The problem with doing this is that it requires me to modify every
> > configure.in. And figure out how to get my option passed on from the top
> > one. This is tedious. Well, worse than tedious. I don't know how to do
> > it.
> 
>     I was thinking of some configure option which adds -Werror in
>     the appropiate place, rather than some manual operation..

So was I, but like I say, I have to do it to each configure.in, and
figure out how to pass one to the other. I presume this is trivial if
you know how, but I don't.

Ideally an option to allow _arbitrary_ compile-time flags would be much
more useful.

Cheers,

Ben.

--
http://www.apache-ssl.org/ben.html

"There is no limit to what a man can do or how far he can go if he
doesn't mind who gets the credit." - Robert Woodruff

Re: cvs commit: httpd-2.0/server/mpm/prefork prefork.c

Posted by Sascha Schumann <sa...@schumann.cx>.
> The problem with doing this is that it requires me to modify every
> configure.in. And figure out how to get my option passed on from the top
> one. This is tedious. Well, worse than tedious. I don't know how to do
> it.

    I was thinking of some configure option which adds -Werror in
    the appropiate place, rather than some manual operation..

    - Sascha


Re: cvs commit: httpd-2.0/server/mpm/prefork prefork.c

Posted by Ben Laurie <be...@algroup.co.uk>.
Sascha Schumann wrote:
> 
> > NO THEY CAN'T!!!! Like I keep saying, configure writes such crap C that
> > turning on -Werror causes it to get totally the wrong picture.
> 
>     It writes C code which is expected to work on all systems
>     (i.e. also pre-ANSI C compilers).  That is why ANSI C
>     conforming compilers spit out warnings.
> 
> > Actually, its just possible that "CFLAGS=-Werror ./configure
> > --with-maintainer-mode" would work, but that would be purely by luck.
> > I'd hate to rely on it. It certainly doens't if you switch on -Wall,
> > too.
> 
>     Just do what is sensible:  Add -Werror after running all
>     tests and before substitution time.

The problem with doing this is that it requires me to modify every
configure.in. And figure out how to get my option passed on from the top
one. This is tedious. Well, worse than tedious. I don't know how to do
it.

Cheers,

Ben.

--
http://www.apache-ssl.org/ben.html

"There is no limit to what a man can do or how far he can go if he
doesn't mind who gets the credit." - Robert Woodruff

Re: cvs commit: httpd-2.0/server/mpm/prefork prefork.c

Posted by Sascha Schumann <sa...@schumann.cx>.
> NO THEY CAN'T!!!! Like I keep saying, configure writes such crap C that
> turning on -Werror causes it to get totally the wrong picture.

    It writes C code which is expected to work on all systems
    (i.e. also pre-ANSI C compilers).  That is why ANSI C
    conforming compilers spit out warnings.

> Actually, its just possible that "CFLAGS=-Werror ./configure
> --with-maintainer-mode" would work, but that would be purely by luck.
> I'd hate to rely on it. It certainly doens't if you switch on -Wall,
> too.

    Just do what is sensible:  Add -Werror after running all
    tests and before substitution time.

    - Sascha


Re: cvs commit: httpd-2.0/server/mpm/prefork prefork.c

Posted by Ben Laurie <be...@algroup.co.uk>.
Jeff Trawick wrote:
> 
> Ben Laurie <be...@algroup.co.uk> writes:
> 
> > > > BTW, please can we make maintainer-mode have -Wall in it?
> > >
> > > Last I checked, it did.
> >
> > Apologies. I meant -Werror.
> 
> Ouch...  I use --with-maintainer-mode with the regression builds.
> What this will mean for me is that once a warning is picked up (not a
> rare occurrence) in some code I won't be able to track warnings
> introduced in other code until the first is fixed.  Obviously we won't
> do any run-time tests either :)
> 
> Beyond my regression builds, it means that Joe Blow (or Jeff Blow, as
> the case may be) who may not be the best person to fix warnings
> somebody just introduced has to dumb down the warning flags to get
> Apache to build and may inadvertently introduce even more suspicious
> code in the meantime.
> 
> -1 on adding -Werror to the set of maintainer-mode flags
> 
> Warnings get handled appropriately in relatively short order.
> 
> People can always add -Werror manually ("CFLAGS=-Werror ./configure" I
> think) or save stderr (shudder).

NO THEY CAN'T!!!! Like I keep saying, configure writes such crap C that
turning on -Werror causes it to get totally the wrong picture.

Actually, its just possible that "CFLAGS=-Werror ./configure
--with-maintainer-mode" would work, but that would be purely by luck.
I'd hate to rely on it. It certainly doens't if you switch on -Wall,
too.

Cheers,

Ben.

--
http://www.apache-ssl.org/ben.html

"There is no limit to what a man can do or how far he can go if he
doesn't mind who gets the credit." - Robert Woodruff

Re: cvs commit: httpd-2.0/server/mpm/prefork prefork.c

Posted by Jeff Trawick <tr...@bellsouth.net>.
Ben Laurie <be...@algroup.co.uk> writes:

> > > BTW, please can we make maintainer-mode have -Wall in it?
> > 
> > Last I checked, it did.
> 
> Apologies. I meant -Werror.

Ouch...  I use --with-maintainer-mode with the regression builds.
What this will mean for me is that once a warning is picked up (not a
rare occurrence) in some code I won't be able to track warnings
introduced in other code until the first is fixed.  Obviously we won't
do any run-time tests either :)

Beyond my regression builds, it means that Joe Blow (or Jeff Blow, as
the case may be) who may not be the best person to fix warnings
somebody just introduced has to dumb down the warning flags to get
Apache to build and may inadvertently introduce even more suspicious
code in the meantime.

-1 on adding -Werror to the set of maintainer-mode flags

Warnings get handled appropriately in relatively short order.

People can always add -Werror manually ("CFLAGS=-Werror ./configure" I
think) or save stderr (shudder).

-- 
Jeff Trawick | trawickj@bellsouth.net | PGP public key at web site:
       http://www.geocities.com/SiliconValley/Park/9289/
             Born in Roswell... married an alien...

Re: cvs commit: httpd-2.0/server/mpm/prefork prefork.c

Posted by Ben Laurie <be...@algroup.co.uk>.
rbb@covalent.net wrote:
> 
> > > Why was this moved?  It worked properly on Linux, and by removing the
> > > one_process=0, it worked on FreeBSD as well.  Just asking, because we
> > > probably want to move the no_detach to the same location.  The basically
> > > do the same thing.
> >
> > It was probably spurious. I moved it initially because I thought it
> > might fix a problem. Then I left it there because it fixed a comment.
> > :-)
> >
> > BTW, please can we make maintainer-mode have -Wall in it?
> 
> Last I checked, it did.

Apologies. I meant -Werror.

Cheers,

Ben.

--
http://www.apache-ssl.org/ben.html

"There is no limit to what a man can do or how far he can go if he
doesn't mind who gets the credit." - Robert Woodruff

Re: cvs commit: httpd-2.0/server/mpm/prefork prefork.c

Posted by Ben Laurie <be...@algroup.co.uk>.
rbb@covalent.net wrote:
> 
> > > Why was this moved?  It worked properly on Linux, and by removing the
> > > one_process=0, it worked on FreeBSD as well.  Just asking, because we
> > > probably want to move the no_detach to the same location.  The basically
> > > do the same thing.
> >
> > It was probably spurious. I moved it initially because I thought it
> > might fix a problem. Then I left it there because it fixed a comment.
> > :-)
> >
> > BTW, please can we make maintainer-mode have -Wall in it?
> 
> Last I checked, it did.

Apologies. I meant -Werror.

Cheers,

Ben.

--
http://www.apache-ssl.org/ben.html

"There is no limit to what a man can do or how far he can go if he
doesn't mind who gets the credit." - Robert Woodruff

Re: cvs commit: httpd-2.0/server/mpm/prefork prefork.c

Posted by rb...@covalent.net.
> > Why was this moved?  It worked properly on Linux, and by removing the
> > one_process=0, it worked on FreeBSD as well.  Just asking, because we
> > probably want to move the no_detach to the same location.  The basically
> > do the same thing.
> 
> It was probably spurious. I moved it initially because I thought it
> might fix a problem. Then I left it there because it fixed a comment.
> :-)
> 
> BTW, please can we make maintainer-mode have -Wall in it? 

Last I checked, it did.

Ryan

_______________________________________________________________________________
Ryan Bloom                        	rbb@apache.org
406 29th St.
San Francisco, CA 94131
-------------------------------------------------------------------------------


Re: cvs commit: httpd-2.0/server/mpm/prefork prefork.c

Posted by rb...@covalent.net.
> > Why was this moved?  It worked properly on Linux, and by removing the
> > one_process=0, it worked on FreeBSD as well.  Just asking, because we
> > probably want to move the no_detach to the same location.  The basically
> > do the same thing.
> 
> It was probably spurious. I moved it initially because I thought it
> might fix a problem. Then I left it there because it fixed a comment.
> :-)
> 
> BTW, please can we make maintainer-mode have -Wall in it? 

Last I checked, it did.

Ryan

_______________________________________________________________________________
Ryan Bloom                        	rbb@apache.org
406 29th St.
San Francisco, CA 94131
-------------------------------------------------------------------------------


Re: cvs commit: httpd-2.0/server/mpm/prefork prefork.c

Posted by Ben Laurie <be...@algroup.co.uk>.
rbb@covalent.net wrote:
> 
> >    #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;
> 
> Can we change the strcmp to a memcmp, since we know that these are static
> strings?

I guess.

> >   @@ -1543,7 +1543,6 @@
> >        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 @@
> >    #ifdef AUX3
> >        (void) set42sig();
> >    #endif
> >   -    /* TODO: set one_process properly */ one_process = 0;
> >   +    one_process = !!getenv("ONE_PROCESS");
> 
> Why was this moved?  It worked properly on Linux, and by removing the
> one_process=0, it worked on FreeBSD as well.  Just asking, because we
> probably want to move the no_detach to the same location.  The basically
> do the same thing.

It was probably spurious. I moved it initially because I thought it
might fix a problem. Then I left it there because it fixed a comment.
:-)

BTW, please can we make maintainer-mode have -Wall in it? 

Cheers,

Ben.

--
http://www.apache-ssl.org/ben.html

"There is no limit to what a man can do or how far he can go if he
doesn't mind who gets the credit." - Robert Woodruff

Re: cvs commit: httpd-2.0/server/mpm/prefork prefork.c

Posted by Ben Laurie <be...@algroup.co.uk>.
rbb@covalent.net wrote:
> 
> >    #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;
> 
> Can we change the strcmp to a memcmp, since we know that these are static
> strings?

I guess.

> >   @@ -1543,7 +1543,6 @@
> >        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 @@
> >    #ifdef AUX3
> >        (void) set42sig();
> >    #endif
> >   -    /* TODO: set one_process properly */ one_process = 0;
> >   +    one_process = !!getenv("ONE_PROCESS");
> 
> Why was this moved?  It worked properly on Linux, and by removing the
> one_process=0, it worked on FreeBSD as well.  Just asking, because we
> probably want to move the no_detach to the same location.  The basically
> do the same thing.

It was probably spurious. I moved it initially because I thought it
might fix a problem. Then I left it there because it fixed a comment.
:-)

BTW, please can we make maintainer-mode have -Wall in it? 

Cheers,

Ben.

--
http://www.apache-ssl.org/ben.html

"There is no limit to what a man can do or how far he can go if he
doesn't mind who gets the credit." - Robert Woodruff

Re: cvs commit: httpd-2.0/server/mpm/prefork prefork.c

Posted by rb...@covalent.net.
>    #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;

Can we change the strcmp to a memcmp, since we know that these are static
strings?

>   @@ -1543,7 +1543,6 @@
>        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 @@
>    #ifdef AUX3
>        (void) set42sig();
>    #endif
>   -    /* TODO: set one_process properly */ one_process = 0;
>   +    one_process = !!getenv("ONE_PROCESS");

Why was this moved?  It worked properly on Linux, and by removing the 
one_process=0, it worked on FreeBSD as well.  Just asking, because we
probably want to move the no_detach to the same location.  The basically
do the same thing.

Ryan
_______________________________________________________________________________
Ryan Bloom                        	rbb@apache.org
406 29th St.
San Francisco, CA 94131
-------------------------------------------------------------------------------


Re: cvs commit: httpd-2.0/server/mpm/prefork prefork.c

Posted by rb...@covalent.net.
>    #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;

Can we change the strcmp to a memcmp, since we know that these are static
strings?

>   @@ -1543,7 +1543,6 @@
>        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 @@
>    #ifdef AUX3
>        (void) set42sig();
>    #endif
>   -    /* TODO: set one_process properly */ one_process = 0;
>   +    one_process = !!getenv("ONE_PROCESS");

Why was this moved?  It worked properly on Linux, and by removing the 
one_process=0, it worked on FreeBSD as well.  Just asking, because we
probably want to move the no_detach to the same location.  The basically
do the same thing.

Ryan
_______________________________________________________________________________
Ryan Bloom                        	rbb@apache.org
406 29th St.
San Francisco, CA 94131
-------------------------------------------------------------------------------