Author: rjung Date: Sun Jan 13 09:01:08 2008 New Revision: 611595 URL: http://svn.apache.org/viewvc?rev=611595&view=rev Log: Differentiate between ajp shm workers and lb sub shm workers part 1: - introduce new shm worker and rename existing one.
Modified: tomcat/connectors/trunk/jk/native/common/jk_lb_worker.c tomcat/connectors/trunk/jk/native/common/jk_lb_worker.h tomcat/connectors/trunk/jk/native/common/jk_shm.c tomcat/connectors/trunk/jk/native/common/jk_shm.h Modified: tomcat/connectors/trunk/jk/native/common/jk_lb_worker.c URL: http://svn.apache.org/viewvc/tomcat/connectors/trunk/jk/native/common/jk_lb_worker.c?rev=611595&r1=611594&r2=611595&view=diff ============================================================================== --- tomcat/connectors/trunk/jk/native/common/jk_lb_worker.c (original) +++ tomcat/connectors/trunk/jk/native/common/jk_lb_worker.c Sun Jan 13 09:01:08 2008 @@ -1353,7 +1353,7 @@ } for (i = 0; i < num_of_workers; i++) { - p->lb_workers[i].s = jk_shm_alloc_ajp13_worker(&p->p); + p->lb_workers[i].s = jk_shm_alloc_lb_sub_worker(&p->p); if (p->lb_workers[i].s == NULL) { jk_log(l, JK_LOG_ERROR, "allocating ajp13 worker record from shared memory"); Modified: tomcat/connectors/trunk/jk/native/common/jk_lb_worker.h URL: http://svn.apache.org/viewvc/tomcat/connectors/trunk/jk/native/common/jk_lb_worker.h?rev=611595&r1=611594&r2=611595&view=diff ============================================================================== --- tomcat/connectors/trunk/jk/native/common/jk_lb_worker.h (original) +++ tomcat/connectors/trunk/jk/native/common/jk_lb_worker.h Sun Jan 13 09:01:08 2008 @@ -37,6 +37,7 @@ #define JK_LB_WORKER_NAME ("lb") #define JK_LB_WORKER_TYPE (5) +#define JK_LB_SUB_WORKER_TYPE (7) #define JK_LB_DEF_DOMAIN_NAME ("unknown") #define JK_LB_METHOD_REQUESTS (0) @@ -122,7 +123,7 @@ { jk_worker_t *w; /* Shared memory worker data */ - jk_shm_ajp13_worker_t *s; + jk_shm_lb_sub_worker_t *s; char name[JK_SHM_STR_SIZ+1]; /* route */ char route[JK_SHM_STR_SIZ+1]; Modified: tomcat/connectors/trunk/jk/native/common/jk_shm.c URL: http://svn.apache.org/viewvc/tomcat/connectors/trunk/jk/native/common/jk_shm.c?rev=611595&r1=611594&r2=611595&view=diff ============================================================================== --- tomcat/connectors/trunk/jk/native/common/jk_shm.c (original) +++ tomcat/connectors/trunk/jk/native/common/jk_shm.c Sun Jan 13 09:01:08 2008 @@ -28,6 +28,7 @@ #include "jk_mt.h" #include "jk_lb_worker.h" #include "jk_ajp13_worker.h" +#include "jk_ajp14_worker.h" #include "jk_shm.h" /** jk shm header core data structure */ @@ -60,7 +61,8 @@ struct jk_shm { size_t size; - unsigned ajp13_workers; + unsigned ajp_workers; + unsigned lb_sub_workers; unsigned lb_workers; char *filename; char *lockname; @@ -74,7 +76,7 @@ typedef struct jk_shm jk_shm_t; static const char shm_signature[] = { JK_SHM_MAGIC }; -static jk_shm_t jk_shmem = { 0, 0, 0, NULL, NULL, -1, -1, 0, NULL}; +static jk_shm_t jk_shmem = { 0, 0, 0, 0, NULL, NULL, -1, -1, 0, NULL}; static time_t jk_workers_modified_time = 0; static time_t jk_workers_access_time = 0; #if defined (WIN32) @@ -87,8 +89,9 @@ char **worker_list; unsigned i; unsigned num_of_workers; + int num_of_ajp_workers = 0; + int num_of_lb_sub_workers = 0; int num_of_lb_workers = 0; - int num_of_ajp13_workers = 0; JK_TRACE_ENTER(l); @@ -103,7 +106,11 @@ for (i = 0; i < num_of_workers; i++) { const char *type = jk_get_worker_type(init_data, worker_list[i]); - if (!strcmp(type, JK_LB_WORKER_NAME)) { + if (!strcmp(type, JK_AJP13_WORKER_NAME) || + !strcmp(type, JK_AJP14_WORKER_NAME)) { + num_of_ajp_workers++; + } + else if (!strcmp(type, JK_LB_WORKER_NAME)) { char **member_list; unsigned num_of_members; num_of_lb_workers++; @@ -116,17 +123,23 @@ if (JK_IS_DEBUG_LEVEL(l)) jk_log(l, JK_LOG_DEBUG, "worker %s of type %s has %u members", worker_list[i], JK_LB_WORKER_NAME, num_of_members); - num_of_ajp13_workers += num_of_members; + num_of_lb_sub_workers += num_of_members; } } } if (JK_IS_DEBUG_LEVEL(l)) - jk_log(l, JK_LOG_DEBUG, "shared memory will contain %d lb workers with %d ajp13 members", - num_of_lb_workers, num_of_ajp13_workers); + jk_log(l, JK_LOG_DEBUG, "shared memory will contain %d ajp workers of size %d and %d lb workers of size %d with %d members of size %d+%d", + num_of_ajp_workers, JK_SHM_AJP_SIZE(1), + num_of_lb_workers, JK_SHM_LB_SIZE(1), + num_of_lb_sub_workers, JK_SHM_LB_SUB_SIZE(1), JK_SHM_AJP_SIZE(1)); + jk_shmem.ajp_workers = num_of_ajp_workers; + jk_shmem.lb_sub_workers = num_of_lb_sub_workers; jk_shmem.lb_workers = num_of_lb_workers; - jk_shmem.ajp13_workers = num_of_ajp13_workers; JK_TRACE_EXIT(l); - return JK_SHM_LB_SIZE(jk_shmem.lb_workers) + JK_SHM_AJP13_SIZE(jk_shmem.ajp13_workers); + return JK_SHM_AJP_SIZE(jk_shmem.ajp_workers) + + JK_SHM_LB_SUB_SIZE(jk_shmem.lb_sub_workers) + + JK_SHM_AJP_SIZE(jk_shmem.lb_sub_workers) + + JK_SHM_LB_SIZE(jk_shmem.lb_workers); } @@ -710,15 +723,31 @@ return rc; } -jk_shm_ajp13_worker_t *jk_shm_alloc_ajp13_worker(jk_pool_t *p) +jk_shm_ajp_worker_t *jk_shm_alloc_ajp_worker(jk_pool_t *p) { - jk_shm_ajp13_worker_t *w = (jk_shm_ajp13_worker_t *)jk_shm_alloc(p, JK_SHM_AJP13_WORKER_SIZE); + jk_shm_ajp_worker_t *w = (jk_shm_ajp_worker_t *)jk_shm_alloc(p, JK_SHM_AJP_WORKER_SIZE); if (w) { - memset(w, 0, JK_SHM_AJP13_WORKER_SIZE); + memset(w, 0, JK_SHM_AJP_WORKER_SIZE); if (jk_shmem.hdr) { jk_shmem.hdr->h.data.workers++; w->h.id = jk_shmem.hdr->h.data.workers; w->h.type = JK_AJP13_WORKER_TYPE; + } + else + w->h.id = -1; + } + return w; +} + +jk_shm_lb_sub_worker_t *jk_shm_alloc_lb_sub_worker(jk_pool_t *p) +{ + jk_shm_lb_sub_worker_t *w = (jk_shm_lb_sub_worker_t *)jk_shm_alloc(p, JK_SHM_LB_SUB_WORKER_SIZE); + if (w) { + memset(w, 0, JK_SHM_LB_SUB_WORKER_SIZE); + if (jk_shmem.hdr) { + jk_shmem.hdr->h.data.workers++; + w->h.id = jk_shmem.hdr->h.data.workers; + w->h.type = JK_LB_SUB_WORKER_TYPE; } else w->h.id = -1; Modified: tomcat/connectors/trunk/jk/native/common/jk_shm.h URL: http://svn.apache.org/viewvc/tomcat/connectors/trunk/jk/native/common/jk_shm.h?rev=611595&r1=611594&r2=611595&view=diff ============================================================================== --- tomcat/connectors/trunk/jk/native/common/jk_shm.h (original) +++ tomcat/connectors/trunk/jk/native/common/jk_shm.h Sun Jan 13 09:01:08 2008 @@ -49,14 +49,16 @@ #define JK_SHM_MAGIC_SIZ 8 /* Really huge numbers, but 64 workers should be enough */ -#define JK_SHM_MAX_WORKERS 64 -#define JK_SHM_ALIGNMENT 64 -#define JK_SHM_ALIGN(x) JK_ALIGN((x), JK_SHM_ALIGNMENT) -#define JK_SHM_AJP13_WORKER_SIZE JK_SHM_ALIGN(sizeof(jk_shm_ajp13_worker_t)) -#define JK_SHM_LB_WORKER_SIZE JK_SHM_ALIGN(sizeof(jk_shm_lb_worker_t)) -#define JK_SHM_AJP13_SIZE(x) ((x) * JK_SHM_AJP13_WORKER_SIZE) -#define JK_SHM_LB_SIZE(x) ((x) * JK_SHM_LB_WORKER_SIZE) -#define JK_SHM_DEF_SIZE JK_SHM_AJP13_SIZE(JK_SHM_MAX_WORKERS) +#define JK_SHM_MAX_WORKERS 64 +#define JK_SHM_ALIGNMENT 64 +#define JK_SHM_ALIGN(x) JK_ALIGN((x), JK_SHM_ALIGNMENT) +#define JK_SHM_AJP_WORKER_SIZE JK_SHM_ALIGN(sizeof(jk_shm_ajp_worker_t)) +#define JK_SHM_LB_SUB_WORKER_SIZE JK_SHM_ALIGN(sizeof(jk_shm_lb_sub_worker_t)) +#define JK_SHM_LB_WORKER_SIZE JK_SHM_ALIGN(sizeof(jk_shm_lb_worker_t)) +#define JK_SHM_AJP_SIZE(x) ((x) * JK_SHM_AJP_WORKER_SIZE) +#define JK_SHM_LB_SUB_SIZE(x) ((x) * JK_SHM_LB_SUB_WORKER_SIZE) +#define JK_SHM_LB_SIZE(x) ((x) * JK_SHM_LB_WORKER_SIZE) +#define JK_SHM_DEF_SIZE JK_SHM_AJP_SIZE(JK_SHM_MAX_WORKERS) + JK_SHM_LB_SUB_SIZE(JK_SHM_MAX_WORKERS) + JK_SHM_LB_SIZE(JK_SHM_MAX_WORKERS) /** jk shm generic worker record structure */ struct jk_shm_worker_header @@ -72,8 +74,39 @@ }; typedef struct jk_shm_worker_header jk_shm_worker_header_t; -/** jk shm ajp13 worker record structure */ -struct jk_shm_ajp13_worker +/** jk shm ajp13/ajp14 worker record structure */ +struct jk_shm_ajp_worker +{ + jk_shm_worker_header_t h; + + /* current error state (runtime) of the worker */ + volatile int state; + /* Statistical data */ + /* Number of currently busy channels */ + volatile int busy; + /* Maximum number of busy channels */ + volatile int max_busy; + volatile time_t error_time; + /* Number of bytes read from remote */ + volatile jk_uint64_t readed; + /* Number of bytes transferred to remote */ + volatile jk_uint64_t transferred; + /* Number of times the worker was used */ + volatile jk_uint64_t used; + /* Number of times the worker was used - snapshot during maintenance */ + volatile jk_uint64_t used_snapshot; + /* Number of non 200 responses */ + volatile jk_uint32_t errors; + /* Decayed number of reply_timeout errors */ + volatile jk_uint32_t reply_timeouts; + /* Number of client errors */ + volatile jk_uint32_t client_errors; + volatile time_t last_maintain_time; +}; +typedef struct jk_shm_ajp_worker jk_shm_ajp_worker_t; + +/** jk shm lb sub worker record structure */ +struct jk_shm_lb_sub_worker { jk_shm_worker_header_t h; @@ -116,7 +149,7 @@ /* Number of client errors */ volatile jk_uint32_t client_errors; }; -typedef struct jk_shm_ajp13_worker jk_shm_ajp13_worker_t; +typedef struct jk_shm_lb_sub_worker jk_shm_lb_sub_worker_t; /** jk shm lb worker record structure */ struct jk_shm_lb_worker @@ -134,7 +167,6 @@ int retries; int lbmethod; int lblock; - /* Service transfer rate time */ volatile time_t last_maintain_time; }; typedef struct jk_shm_lb_worker jk_shm_lb_worker_t; @@ -162,10 +194,15 @@ */ void *jk_shm_alloc(jk_pool_t *p, size_t size); -/* allocate shm ajp13 worker record +/* allocate shm ajp worker record + * If there is no shm present the pool will be used instead + */ +jk_shm_ajp_worker_t *jk_shm_alloc_ajp_worker(jk_pool_t *p); + +/* allocate shm lb sub worker record * If there is no shm present the pool will be used instead */ -jk_shm_ajp13_worker_t *jk_shm_alloc_ajp13_worker(jk_pool_t *p); +jk_shm_lb_sub_worker_t *jk_shm_alloc_lb_sub_worker(jk_pool_t *p); /* allocate shm lb worker record * If there is no shm present the pool will be used instead --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]