mturk 2005/02/17 07:03:15 Modified: jk/native/apache-1.3 mod_jk.c jk/native/apache-2.0 mod_jk.c jk/native/common jk_shm.c jk_shm.h jk/native/iis jk_isapi_plugin.c jk/native/netscape jk_nsapi_plugin.c Log: Add option to set shared memory size. In general the 1MB shuld be more then enoug. But if some has more then 2700 workers and uri mappings that might be the limiting factor. Revision Changes Path 1.70 +25 -2 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.69 retrieving revision 1.70 diff -u -r1.69 -r1.70 --- mod_jk.c 16 Feb 2005 15:09:20 -0000 1.69 +++ mod_jk.c 17 Feb 2005 15:03:15 -0000 1.70 @@ -173,6 +173,7 @@ static jk_logger_t *main_log = NULL; static jk_worker_env_t worker_env; static char *jk_shm_file = NULL; +static size_t jk_shm_size = JK_SHM_DEF_SIZE; static int JK_METHOD ws_start_response(jk_ws_service_t *s, int status, @@ -853,6 +854,26 @@ } /* + * JkShmSize Directive Handling + * + * JkShmSize size in kilobytes + */ + +static const char *jk_set_shm_size(cmd_parms * cmd, + void *dummy, const char *shm_size) +{ + int sz = 0; + /* we need an absolute path */ + sz = atoi(shm_size) * 1024; + if (sz < JK_SHM_DEF_SIZE) + sz = JK_SHM_DEF_SIZE; + else + sz = JK_SHM_ALIGN(sz); + jk_shm_size = (size_t)sz; + return NULL; +} + +/* * JkLogLevel Directive Handling * * JkLogLevel debug/info/request/error/emerg @@ -1534,6 +1555,8 @@ "Full path to the Jakarta mod_jk module log file"}, {"JkShmFile", jk_set_shm_file, NULL, RSRC_CONF, TAKE1, "Full path to the Jakarta mod_jk module shared memory file"}, + {"JkShmSize", jk_set_shm_size, NULL, RSRC_CONF, TAKE1, + "Size of the shared memory file in KBytes"}, {"JkLogLevel", jk_set_log_level, NULL, RSRC_CONF, TAKE1, "The Jakarta mod_jk module log level, can be debug, info, request, error, or emerg"}, {"JkLogStampFormat", jk_set_log_fmt, NULL, RSRC_CONF, TAKE1, @@ -1909,7 +1932,7 @@ } } - if ((rc = jk_shm_open(jk_shm_file, conf->log)) == 0) { + if ((rc = jk_shm_open(jk_shm_file, jk_shm_size, conf->log)) == 0) { if (JK_IS_DEBUG_LEVEL(conf->log)) jk_log(conf->log, JK_LOG_DEBUG, "Initialized shm:%s", jk_shm_name(), rc); 1.127 +27 -3 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.126 retrieving revision 1.127 diff -u -r1.126 -r1.127 --- mod_jk.c 16 Feb 2005 15:09:20 -0000 1.126 +++ mod_jk.c 17 Feb 2005 15:03:15 -0000 1.127 @@ -190,6 +190,7 @@ static jk_worker_env_t worker_env; static apr_global_mutex_t *jk_log_lock = NULL; static char *jk_shm_file = NULL; +static size_t jk_shm_size = JK_SHM_DEF_SIZE; static int JK_METHOD ws_start_response(jk_ws_service_t *s, int status, @@ -886,6 +887,26 @@ } /* + * JkShmSize Directive Handling + * + * JkShmSize size in kilobytes + */ + +static const char *jk_set_shm_size(cmd_parms * cmd, + void *dummy, const char *shm_size) +{ + int sz = 0; + /* we need an absolute path */ + sz = atoi(shm_size) * 1024; + if (sz < JK_SHM_DEF_SIZE) + sz = JK_SHM_DEF_SIZE; + else + sz = JK_SHM_ALIGN(sz); + jk_shm_size = (size_t)sz; + return NULL; +} + +/* * JkLogLevel Directive Handling * * JkLogLevel debug/info/error/emerg @@ -1580,6 +1601,9 @@ AP_INIT_TAKE1("JkShmFile", jk_set_shm_file, NULL, RSRC_CONF, "Full path to the Jakarta Tomcat module shared memory file"), + AP_INIT_TAKE1("JkShmSize", jk_set_shm_size, NULL, RSRC_CONF, + "Size of the shared memory file in KBytes"), + AP_INIT_TAKE1("JkLogLevel", jk_set_log_level, NULL, RSRC_CONF, "The Jakarta Tomcat module log level, can be debug, " "info, error or emerg"), @@ -2239,7 +2263,7 @@ JK_TRACE_ENTER(conf->log); - if ((rc = jk_shm_attach(jk_shm_file, conf->log)) == 0) { + if ((rc = jk_shm_attach(jk_shm_file, jk_shm_size, conf->log)) == 0) { if (JK_IS_DEBUG_LEVEL(conf->log)) jk_log(conf->log, JK_LOG_DEBUG, "Attached shm:%s", jk_shm_name()); @@ -2273,7 +2297,7 @@ /* jk_map_t *init_map = NULL; */ jk_map_t *init_map = conf->worker_properties; - if ((rc = jk_shm_open(jk_shm_file, conf->log)) == 0) { + if ((rc = jk_shm_open(jk_shm_file, jk_shm_size, conf->log)) == 0) { if (JK_IS_DEBUG_LEVEL(conf->log)) jk_log(conf->log, JK_LOG_DEBUG, "Initialized shm:%s", jk_shm_name(), rc); 1.14 +14 -13 jakarta-tomcat-connectors/jk/native/common/jk_shm.c Index: jk_shm.c =================================================================== RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native/common/jk_shm.c,v retrieving revision 1.13 retrieving revision 1.14 diff -u -r1.13 -r1.14 --- jk_shm.c 15 Feb 2005 11:41:26 -0000 1.13 +++ jk_shm.c 17 Feb 2005 15:03:15 -0000 1.14 @@ -62,7 +62,7 @@ #if defined (WIN32) || defined(NETWARE) /* Use plain memory */ -int jk_shm_open(const char *fname, jk_logger_t *l) +int jk_shm_open(const char *fname, size_t sz, jk_logger_t *l) { int rc; JK_TRACE_ENTER(l); @@ -73,7 +73,7 @@ return 0; } - jk_shmem.size = JK_SHM_ALIGN(sizeof(jk_shm_header_t) + JK_SHM_SIZE); + jk_shmem.size = JK_SHM_ALIGN(sizeof(jk_shm_header_t) + sz); jk_shmem.hdr = (jk_shm_header_t *)calloc(1, jk_shmem.size); if (!jk_shmem.hdr) { @@ -84,7 +84,7 @@ jk_shmem.fd = 0; jk_shmem.attached = 0; memcpy(jk_shmem.hdr->magic, shm_signature, 8); - jk_shmem.hdr->size = JK_SHM_SIZE; + jk_shmem.hdr->size = sz; JK_INIT_CS(&(jk_shmem.cs), rc); if (JK_IS_DEBUG_LEVEL(l)) jk_log(l, JK_LOG_DEBUG, @@ -94,10 +94,10 @@ return 0; } -int jk_shm_attach(const char *fname, jk_logger_t *l) +int jk_shm_attach(const char *fname, size_t sz, jk_logger_t *l) { JK_TRACE_ENTER(l); - if (!jk_shm_open(fname, l)) { + if (!jk_shm_open(fname, sz, l)) { jk_shmem.attached = 1; jk_shmem.hdr->childs++; if (JK_IS_DEBUG_LEVEL(l)) @@ -184,7 +184,8 @@ return 0; } -static int do_shm_open(const char *fname, int attached, jk_logger_t *l) +static int do_shm_open(const char *fname, int attached, + size_t sz, jk_logger_t *l) { int rc; int fd; @@ -202,7 +203,7 @@ jk_shmem.filename = fname; jk_shmem.attached = attached; - jk_shmem.size = JK_SHM_ALIGN(sizeof(jk_shm_header_t) + JK_SHM_SIZE); + jk_shmem.size = JK_SHM_ALIGN(sizeof(jk_shm_header_t) + sz); /* Use plain memory in case there is no file name */ if (!fname) { @@ -265,7 +266,7 @@ if (!attached) { memset(jk_shmem.hdr, 0, jk_shmem.size); memcpy(jk_shmem.hdr->magic, shm_signature, 8); - jk_shmem.hdr->size = JK_SHM_SIZE; + jk_shmem.hdr->size = sz; if (JK_IS_DEBUG_LEVEL(l)) jk_log(l, JK_LOG_DEBUG, "Initialized shared memory size=%u free=%u addr=%#lx", @@ -294,14 +295,14 @@ return 0; } -int jk_shm_open(const char *fname, jk_logger_t *l) +int jk_shm_open(const char *fname, size_t sz, jk_logger_t *l) { - return do_shm_open(fname, 0, l); + return do_shm_open(fname, 0, sz, l); } -int jk_shm_attach(const char *fname, jk_logger_t *l) +int jk_shm_attach(const char *fname, size_t sz, jk_logger_t *l) { - return do_shm_open(fname, 1, l); + return do_shm_open(fname, 1, sz, l); } void jk_shm_close() 1.12 +5 -5 jakarta-tomcat-connectors/jk/native/common/jk_shm.h Index: jk_shm.h =================================================================== RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native/common/jk_shm.h,v retrieving revision 1.11 retrieving revision 1.12 diff -u -r1.11 -r1.12 --- jk_shm.h 16 Feb 2005 08:25:10 -0000 1.11 +++ jk_shm.h 17 Feb 2005 15:03:15 -0000 1.12 @@ -47,8 +47,8 @@ /* Really huge numbers, but 512 workers should be enough */ #define JK_SHM_MAX_WORKERS 512 -#define JK_SHM_SIZE (1024 * 1024) -#define JK_SHM_ALIGN(x) JK_ALIGN(x, 1024) +#define JK_SHM_DEF_SIZE (1024 * 1024) +#define JK_SHM_ALIGN(x) JK_ALIGN(x, 1024) /** jk shm worker record structure */ struct jk_shm_worker @@ -107,7 +107,7 @@ /* Open the shared memory creating file if needed */ -int jk_shm_open(const char *fname, jk_logger_t *l); +int jk_shm_open(const char *fname, size_t sz, jk_logger_t *l); /* Close the shared memory */ @@ -116,7 +116,7 @@ /* Attach the shared memory in child process. * File has to be opened in parent. */ -int jk_shm_attach(const char *fname, jk_logger_t *l); +int jk_shm_attach(const char *fname, size_t sz, jk_logger_t *l); /* allocate shm memory * If there is no shm present the pool will be used instead 1.40 +5 -3 jakarta-tomcat-connectors/jk/native/iis/jk_isapi_plugin.c Index: jk_isapi_plugin.c =================================================================== RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native/iis/jk_isapi_plugin.c,v retrieving revision 1.39 retrieving revision 1.40 diff -u -r1.39 -r1.40 --- jk_isapi_plugin.c 16 Feb 2005 15:09:21 -0000 1.39 +++ jk_isapi_plugin.c 17 Feb 2005 15:03:15 -0000 1.40 @@ -1032,8 +1032,10 @@ if (!jk_open_file_logger(&logger, log_file, log_level)) { logger = NULL; } - /* Simulate shared memory */ - jk_shm_open(NULL, logger); + /* Simulate shared memory + * For now use fixed size. + */ + jk_shm_open(NULL, JK_SHM_DEF_SIZE, logger); /* Logging the initialization type: registry or properties file in virtual dir */ 1.21 +5 -5 jakarta-tomcat-connectors/jk/native/netscape/jk_nsapi_plugin.c Index: jk_nsapi_plugin.c =================================================================== RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native/netscape/jk_nsapi_plugin.c,v retrieving revision 1.20 retrieving revision 1.21 diff -u -r1.20 -r1.21 --- jk_nsapi_plugin.c 15 Feb 2005 12:03:31 -0000 1.20 +++ jk_nsapi_plugin.c 17 Feb 2005 15:03:15 -0000 1.21 @@ -20,7 +20,7 @@ * Version: $Revision$ * ***************************************************************************/ -
+ #include "nsapi.h" #include "jk_global.h" #include "jk_util.h" @@ -28,7 +28,7 @@ #include "jk_pool.h" #include "jk_service.h" #include "jk_worker.h" -#include "jk_shm.h" +#include "jk_shm.h" #define URI_PATTERN "path" #define DEFAULT_WORKER_NAME ("ajp13") @@ -212,7 +212,7 @@ char *worker_prp_file = pblock_findval(JK_WORKER_FILE_TAG, pb); char *log_level_str = pblock_findval(JK_LOG_LEVEL_TAG, pb); char *log_file = pblock_findval(JK_LOG_FILE_TAG, pb); - char *shm_file = pblock_findval(JK_SHM_FILE_TAG, pb); + char *shm_file = pblock_findval(JK_SHM_FILE_TAG, pb); int rc = REQ_ABORTED; jk_map_t *init_map; @@ -232,8 +232,8 @@ jk_parse_log_level(log_level_str))) { logger = NULL; } - - jk_shm_open(shm_file, logger); + + jk_shm_open(shm_file, JK_SHM_DEF_SIZE, logger); if (jk_map_alloc(&init_map)) { if (jk_map_read_properties(init_map, worker_prp_file)) { int sleep_cnt; --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]