mturk       2005/02/06 03:21:38

  Modified:    jk/native/apache-2.0 mod_jk.c
  Log:
  Initialize shared memory and attach in child process.
  
  Revision  Changes    Path
  1.118     +57 -1     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.117
  retrieving revision 1.118
  diff -u -r1.117 -r1.118
  --- mod_jk.c  6 Feb 2005 09:33:15 -0000       1.117
  +++ mod_jk.c  6 Feb 2005 11:21:37 -0000       1.118
  @@ -95,6 +95,7 @@
   #include "jk_uri_worker_map.h"
   #include "jk_util.h"
   #include "jk_worker.h"
  +#include "jk_shm.h"
   
   #define JK_WORKER_ID        ("jakarta.worker")
   #define JK_HANDLER          ("jakarta-servlet")
  @@ -188,6 +189,8 @@
   static jk_logger_t *main_log = NULL;
   static jk_worker_env_t worker_env;
   static apr_global_mutex_t *jk_log_lock = NULL;
  +static char *jk_shm_file = NULL;
  +static jk_shm_t jk_shmem = { 0, NULL, -1, NULL, 0};
   
   static int JK_METHOD ws_start_response(jk_ws_service_t *s,
                                          int status,
  @@ -867,6 +870,23 @@
   }
   
   /*
  + * JkShmFile Directive Handling
  + *
  + * JkShmFile file
  + */
  +
  +static const char *jk_set_shm_file(cmd_parms * cmd,
  +                                   void *dummy, const char *shm_file)
  +{
  +    /* we need an absolute path */
  +    jk_shm_file = ap_server_root_relative(cmd->pool, shm_file);
  +    if (jk_shm_file == NULL)
  +        return "JkShmFile file name invalid";
  +
  +    return NULL;
  +}
  +
  +/*
    * JkLogLevel Directive Handling
    *
    * JkLogLevel debug/info/error/emerg
  @@ -1557,6 +1577,10 @@
        */
       AP_INIT_TAKE1("JkLogFile", jk_set_log_file, NULL, RSRC_CONF,
                     "Full path to the Jakarta Tomcat module log file"),
  +
  +    AP_INIT_TAKE1("JkShmFile", jk_set_shm_file, NULL, RSRC_CONF,
  +                  "Full path to the Jakarta Tomcat module shared memory 
file"),
  +
       AP_INIT_TAKE1("JkLogLevel", jk_set_log_level, NULL, RSRC_CONF,
                     "The Jakarta Tomcat module log level, can be debug, "
                     "info, error or emerg"),
  @@ -1642,6 +1666,17 @@
       return 0;
   }
   
  +/** Util - cleanup shmem.
  + */
  +apr_status_t jk_cleanup_shmem(void *data)
  +{
  +    if (jk_shmem.base) {
  +    jk_shm_close(&jk_shmem);
  +    jk_shmem.base = NULL;
  +    }
  +    return 0;
  +}
  +
   /** Main service method, called to forward a request to tomcat
    */
   static int jk_handler(request_rec * r)
  @@ -2192,6 +2227,7 @@
       jk_server_conf_t *conf;
       int mpm_threads = 1;
       apr_status_t rv;
  +    int rc;
   
       conf = ap_get_module_config(s->module_config, &jk_module);
   
  @@ -2211,6 +2247,16 @@
   #endif
       if (mpm_threads > 0)
           jk_set_worker_def_cache_size(mpm_threads);
  +
  +    rc = jk_shm_attach(jk_shm_file, 0, 0, &jk_shmem);
  +    if (JK_IS_DEBUG_LEVEL(conf->log))
  +        jk_log(conf->log, JK_LOG_DEBUG, "Attached shm:%s with status %d",
  +               jk_shm_file ? jk_shm_file : "memory", rc);
  +    if (!rc) {
  +            apr_pool_cleanup_register(pconf, s, jk_cleanup_shmem,
  +                                     jk_cleanup_shmem);
  +    }
  +
       if (JK_IS_DEBUG_LEVEL(conf->log))
           jk_log(conf->log, JK_LOG_DEBUG, "Initialized %s", 
JK_EXPOSED_VERSION);
       JK_TRACE_EXIT(conf->log);
  @@ -2228,9 +2274,19 @@
   static void init_jk(apr_pool_t * pconf, jk_server_conf_t * conf,
                       server_rec * s)
   {
  +    int rc;
       /*     jk_map_t *init_map = NULL; */
       jk_map_t *init_map = conf->worker_properties;
   
  +    rc = jk_shm_open(jk_shm_file, 0, 0, &jk_shmem);
  +    if (JK_IS_DEBUG_LEVEL(conf->log))
  +        jk_log(conf->log, JK_LOG_DEBUG, "Initialized shm:%s with status %d",
  +               jk_shm_file ? jk_shm_file : "memory", rc);
  +    if (!rc) {
  +            apr_pool_cleanup_register(pconf, s, jk_cleanup_shmem,
  +                                      jk_cleanup_shmem);
  +    }
  +
       if (!uri_worker_map_alloc(&(conf->uw_map),
                                 conf->uri_to_context,
                                 conf->log)) {
  
  
  

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

Reply via email to