mturk       2005/02/21 00:29:17

  Modified:    jk/native/apache-1.3 mod_jk.c
               jk/native/apache-2.0 mod_jk.c
  Log:
  Add JkMountFile directive. This enables to dynamically add or remove
  uri mappings without restarting apache. To disable uri mapping add a
  minus '-' sign in front of mapping.
  
  Revision  Changes    Path
  1.71      +52 -3     jakarta-tomcat-connectors/jk/native/apache-1.3/mod_jk.c
  
  Index: mod_jk.c
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native/apache-1.3/mod_jk.c,v
  retrieving revision 1.70
  retrieving revision 1.71
  diff -u -r1.70 -r1.71
  --- mod_jk.c  17 Feb 2005 15:03:15 -0000      1.70
  +++ mod_jk.c  21 Feb 2005 08:29:17 -0000      1.71
  @@ -95,6 +95,7 @@
        */
       jk_map_t *worker_properties;
       char *worker_file;
  +    char *mount_file;
       jk_map_t *uri_to_context;
   
       int mountcopy;
  @@ -798,6 +799,38 @@
   }
   
   /*
  + * JkMountFile Directive Handling
  + *
  + * JkMountFile file
  + */
  +
  +static const char *jk_set_mount_file(cmd_parms * cmd,
  +                                     void *dummy, char *mount_file)
  +{
  +    server_rec *s = cmd->server;
  +    struct stat statbuf;
  +
  +    jk_server_conf_t *conf =
  +        (jk_server_conf_t *) ap_get_module_config(s->module_config,
  +                                                  &jk_module);
  +
  +    /* we need an absolut path (ap_server_root_relative does the ap_pstrdup) 
*/
  +    conf->mount_file = ap_server_root_relative(cmd->pool, mount_file);
  +
  +#ifdef CHROOTED_APACHE
  +    ap_server_strip_chroot(conf->mount_file, 0);
  +#endif
  +
  +    if (conf->mount_file == NULL)
  +        return "JkMountFile file name invalid";
  +
  +    if (stat(conf->mount_file, &statbuf) == -1)
  +        return "Can't find the mount file specified";
  +
  +    return NULL;
  +}
  +
  +/*
    * JkLogFile Directive Handling
    *
    * JkLogFile file
  @@ -1519,6 +1552,16 @@
        "the name of a worker file for the Jakarta servlet containers"},
   
       /*
  +     * JkMountFile specifies a full path to the location of the
  +     * uriworker properties file.
  +     *
  +     * This file defines the different mapping for workers used by apache
  +     * to redirect servlet requests.
  +     */
  +    {"JkMountFile", jk_set_mount_file, NULL, RSRC_CONF, TAKE1,
  +     "the name of a mount file for the Jakarta servlet uri mappings"},
  +
  +    /*
        * JkAutoMount specifies that the list of handled URLs must be
        * asked to the servlet engine (autoconf feature)
        */
  @@ -1788,6 +1831,7 @@
       c->worker_properties = NULL;
       jk_map_alloc(&c->worker_properties);
       c->worker_file = NULL;
  +    c->mount_file = NULL;
       c->log_file = NULL;
       c->log_level = -1;
       c->log = NULL;
  @@ -1883,6 +1927,7 @@
           copy_jk_map(p, overrides->s, base->uri_to_context,
                       overrides->uri_to_context);
           copy_jk_map(p, overrides->s, base->automount, overrides->automount);
  +        overrides->mount_file = base->mount_file;
       }
   
       if (base->envvars_in_use) {
  @@ -1964,7 +2009,7 @@
   
       /*if(map_alloc(&init_map)) { */
   
  -    if (!jk_map_read_properties(init_map, conf->worker_file)) {
  +    if (!jk_map_read_properties(init_map, conf->worker_file, NULL)) {
   
           if (jk_map_size(init_map) == 0) {
               ap_log_error(APLOG_MARK, APLOG_ERR, NULL,
  @@ -1984,7 +2029,11 @@
       worker_env.virtual = "*";       /* for now */
       worker_env.server_name = (char *)ap_get_server_version();
       if (wc_open(init_map, &worker_env, conf->log)) {
  -        /* we don't need this any more so free it */
  +        /* XXX: For each virtual host? */
  +        if (conf && conf->mount_file) {
  +            conf->uw_map->fname = conf->mount_file;
  +            uri_worker_map_load(conf->uw_map, conf->log);
  +        }
           return;
       }
   
  
  
  
  1.128     +56 -7     jakarta-tomcat-connectors/jk/native/apache-2.0/mod_jk.c
  
  Index: mod_jk.c
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native/apache-2.0/mod_jk.c,v
  retrieving revision 1.127
  retrieving revision 1.128
  diff -u -r1.127 -r1.128
  --- mod_jk.c  17 Feb 2005 15:03:15 -0000      1.127
  +++ mod_jk.c  21 Feb 2005 08:29:17 -0000      1.128
  @@ -130,6 +130,7 @@
        */
       jk_map_t *worker_properties;
       char *worker_file;
  +    char *mount_file;
       jk_map_t *uri_to_context;
   
       int mountcopy;
  @@ -844,6 +845,34 @@
   }
   
   /*
  + * JkMountFile Directive Handling
  + *
  + * JkMountFile file
  + */
  +
  +static const char *jk_set_mount_file(cmd_parms * cmd,
  +                                     void *dummy, const char *mount_file)
  +{
  +    server_rec *s = cmd->server;
  +    struct stat statbuf;
  +
  +    jk_server_conf_t *conf =
  +        (jk_server_conf_t *) ap_get_module_config(s->module_config,
  +                                                  &jk_module);
  +
  +    /* we need an absolut path (ap_server_root_relative does the ap_pstrdup) 
*/
  +    conf->mount_file = ap_server_root_relative(cmd->pool, mount_file);
  +
  +    if (conf->mount_file == NULL)
  +        return "JkMountFile file name invalid";
  +
  +    if (stat(conf->mount_file, &statbuf) == -1)
  +        return "Can't find the mount file specified";
  +
  +    return NULL;
  +}
  +
  +/*
    * JkLogFile Directive Handling
    *
    * JkLogFile file
  @@ -1563,6 +1592,16 @@
                     "the name of a worker file for the Jakarta servlet 
containers"),
   
       /*
  +     * JkMountFile specifies a full path to the location of the
  +     * uriworker properties file.
  +     *
  +     * This file defines the different mapping for workers used by apache
  +     * to redirect servlet requests.
  +     */
  +    AP_INIT_TAKE1("JkMountFile", jk_set_mount_file, NULL, RSRC_CONF,
  +                  "the name of a mount file for the Jakarta servlet uri 
mapping"),
  +
  +    /*
        * JkAutoMount specifies that the list of handled URLs must be
        * asked to the servlet engine (autoconf feature)
        */
  @@ -1997,6 +2036,7 @@
       c->worker_properties = NULL;
       jk_map_alloc(&c->worker_properties);
       c->worker_file = NULL;
  +    c->mount_file = NULL;
       c->log_file = NULL;
       c->log_level = -1;
       c->log = NULL;
  @@ -2097,6 +2137,7 @@
           copy_jk_map(p, overrides->s, base->uri_to_context,
                       overrides->uri_to_context);
           copy_jk_map(p, overrides->s, base->automount, overrides->automount);
  +        overrides->mount_file = base->mount_file;
       }
   
       if (base->envvars_in_use) {
  @@ -2324,7 +2365,7 @@
       }
   
       /*     if(map_alloc(&init_map)) { */
  -    if (!jk_map_read_properties(init_map, conf->worker_file)) {
  +    if (!jk_map_read_properties(init_map, conf->worker_file, NULL)) {
           if (jk_map_size(init_map) == 0) {
               ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO,
                            APLOG_EMERG, NULL,
  @@ -2339,7 +2380,7 @@
       worker_env.uri_to_worker = conf->uw_map;
       worker_env.virtual = "*";   /* for now */
       worker_env.server_name = (char *)ap_get_server_version();
  -    if (wc_open(init_map, &worker_env, conf->log)) {
  +    if (wc_open(init_map, &worker_env, conf->log)) {        
           ap_add_version_component(pconf, JK_EXPOSED_VERSION);
       }
   }
  @@ -2349,6 +2390,8 @@
                             apr_pool_t * ptemp, server_rec * s)
   {
       apr_status_t rv;
  +    jk_server_conf_t *conf;
  +    server_rec *srv = s;
   
       /* create the jk log lockfiles in the parent */
       if ((rv = apr_global_mutex_create(&jk_log_lock, NULL,
  @@ -2370,11 +2413,9 @@
   #endif
   
       if (!s->is_virtual) {
  -        jk_server_conf_t *conf =
  -            (jk_server_conf_t *) ap_get_module_config(s->module_config,
  -                                                      &jk_module);
  +        conf = (jk_server_conf_t *)ap_get_module_config(s->module_config,
  +                                                        &jk_module);
           if (!conf->was_initialized) {
  -            server_rec *srv = s;
               conf->was_initialized = JK_TRUE;
               /* step through the servers and open each jk logfile.
                */
  @@ -2385,6 +2426,14 @@
               init_jk(pconf, conf, s);
           }
       }
  +    for (srv = s; srv; srv = srv->next) {
  +        conf = (jk_server_conf_t *)ap_get_module_config(srv->module_config,
  +                                                        &jk_module);
  +        if (conf && conf->mount_file) {
  +            conf->uw_map->fname = conf->mount_file;
  +            uri_worker_map_load(conf->uw_map, conf->log);
  +        }
  +    }
   
       return OK;
   }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to