Author: rjung
Date: Sun Jan 6 13:14:08 2008
New Revision: 609404
URL: http://svn.apache.org/viewvc?rev=609404&view=rev
Log:
Use distinct structs for lb and ajp13 in shm.
Improves type safety and saves a few bytes.
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
tomcat/connectors/trunk/jk/xdocs/miscellaneous/changelog.xml
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=609404&r1=609403&r2=609404&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 6 13:14:08
2008
@@ -1305,10 +1305,10 @@
}
for (i = 0; i < num_of_workers; i++) {
- p->lb_workers[i].s = jk_shm_alloc_worker(&p->p);
+ p->lb_workers[i].s = jk_shm_alloc_ajp13_worker(&p->p);
if (p->lb_workers[i].s == NULL) {
jk_log(l, JK_LOG_ERROR,
- "allocating worker record from shared memory");
+ "allocating ajp13 worker record from shared
memory");
JK_TRACE_EXIT(l);
return JK_FALSE;
}
@@ -1518,7 +1518,7 @@
private_data->buf,
sizeof(jk_pool_atom_t) * TINY_POOL_SIZE);
- private_data->s = jk_shm_alloc_worker(&private_data->p);
+ private_data->s = jk_shm_alloc_lb_worker(&private_data->p);
if (!private_data->s) {
free(private_data);
JK_TRACE_EXIT(l);
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=609404&r1=609403&r2=609404&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 6 13:14:08
2008
@@ -120,11 +120,11 @@
struct worker_record
{
- jk_worker_t *w;
+ jk_worker_t *w;
/* Shared memory worker data */
- jk_shm_worker_t *s;
+ jk_shm_ajp13_worker_t *s;
/* Current route. Can be name or domain */
- const char *r;
+ const char *r;
};
typedef struct worker_record worker_record_t;
@@ -152,7 +152,7 @@
JK_CRIT_SEC cs;
/* Shared memory worker data */
- jk_shm_worker_t *s;
+ jk_shm_lb_worker_t *s;
};
typedef struct lb_worker lb_worker_t;
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=609404&r1=609403&r2=609404&view=diff
==============================================================================
--- tomcat/connectors/trunk/jk/native/common/jk_shm.c (original)
+++ tomcat/connectors/trunk/jk/native/common/jk_shm.c Sun Jan 6 13:14:08 2008
@@ -27,6 +27,7 @@
#include "jk_util.h"
#include "jk_mt.h"
#include "jk_lb_worker.h"
+#include "jk_ajp13_worker.h"
#include "jk_shm.h"
/** jk shm header core data structure */
@@ -59,7 +60,8 @@
struct jk_shm
{
size_t size;
- unsigned workers;
+ unsigned ajp13_workers;
+ unsigned lb_workers;
char *filename;
char *lockname;
int fd;
@@ -72,7 +74,7 @@
typedef struct jk_shm jk_shm_t;
static const char shm_signature[] = { JK_SHM_MAGIC };
-static jk_shm_t jk_shmem = { 0, 0, NULL, NULL, -1, -1, 0, NULL};
+static jk_shm_t jk_shmem = { 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)
@@ -85,7 +87,8 @@
char **worker_list;
unsigned i;
unsigned num_of_workers;
- int num_of_shm_workers = 0;
+ int num_of_lb_workers = 0;
+ int num_of_ajp13_workers = 0;
JK_TRACE_ENTER(l);
@@ -103,7 +106,7 @@
if (!strcmp(type, JK_LB_WORKER_NAME)) {
char **member_list;
unsigned num_of_members;
- num_of_shm_workers++;
+ num_of_lb_workers++;
if (jk_get_lb_worker_list(init_data, worker_list[i],
&member_list, &num_of_members) ==
JK_FALSE) {
jk_log(l, JK_LOG_ERROR,
@@ -113,15 +116,17 @@
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_shm_workers += num_of_members;
+ num_of_ajp13_workers += num_of_members;
}
}
}
if (JK_IS_DEBUG_LEVEL(l))
- jk_log(l, JK_LOG_DEBUG, "shared memory will contain %d items",
num_of_shm_workers);
- jk_shmem.workers = num_of_shm_workers;
+ 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_shmem.lb_workers = num_of_lb_workers;
+ jk_shmem.ajp13_workers = num_of_ajp13_workers;
JK_TRACE_EXIT(l);
- return JK_SHM_SIZE(jk_shmem.workers);
+ return JK_SHM_LB_SIZE(jk_shmem.lb_workers) +
JK_SHM_AJP13_SIZE(jk_shmem.ajp13_workers);
}
@@ -705,14 +710,31 @@
return rc;
}
-jk_shm_worker_t *jk_shm_alloc_worker(jk_pool_t *p)
+jk_shm_ajp13_worker_t *jk_shm_alloc_ajp13_worker(jk_pool_t *p)
{
- jk_shm_worker_t *w = (jk_shm_worker_t *)jk_shm_alloc(p,
JK_SHM_WORKER_SIZE);
+ jk_shm_ajp13_worker_t *w = (jk_shm_ajp13_worker_t *)jk_shm_alloc(p,
JK_SHM_AJP13_WORKER_SIZE);
if (w) {
- memset(w, 0, JK_SHM_WORKER_SIZE);
+ memset(w, 0, JK_SHM_AJP13_WORKER_SIZE);
if (jk_shmem.hdr) {
jk_shmem.hdr->h.data.workers++;
w->id = jk_shmem.hdr->h.data.workers;
+ w->type = JK_AJP13_WORKER_TYPE;
+ }
+ else
+ w->id = -1;
+ }
+ return w;
+}
+
+jk_shm_lb_worker_t *jk_shm_alloc_lb_worker(jk_pool_t *p)
+{
+ jk_shm_lb_worker_t *w = (jk_shm_lb_worker_t *)jk_shm_alloc(p,
JK_SHM_LB_WORKER_SIZE);
+ if (w) {
+ memset(w, 0, JK_SHM_LB_WORKER_SIZE);
+ if (jk_shmem.hdr) {
+ jk_shmem.hdr->h.data.workers++;
+ w->id = jk_shmem.hdr->h.data.workers;
+ w->type = JK_LB_WORKER_TYPE;
}
else
w->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=609404&r1=609403&r2=609404&view=diff
==============================================================================
--- tomcat/connectors/trunk/jk/native/common/jk_shm.h (original)
+++ tomcat/connectors/trunk/jk/native/common/jk_shm.h Sun Jan 6 13:14:08 2008
@@ -49,27 +49,26 @@
#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_WORKER_SIZE JK_SHM_ALIGN(sizeof(jk_shm_worker_t))
-#define JK_SHM_SIZE(x) ((x) * JK_SHM_WORKER_SIZE)
-#define JK_SHM_DEF_SIZE JK_SHM_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_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)
-/** jk shm worker record structure */
-struct jk_shm_worker
+/** jk shm ajp13 worker record structure */
+struct jk_shm_ajp13_worker
{
int id;
- /* Sequence counter starting at 0 and increasing
- * every time we change the config
- */
- volatile unsigned int sequence;
+ int type;
+ /* worker name */
+ char name[JK_SHM_STR_SIZ+1];
/* Number of currently busy channels */
volatile int busy;
/* Maximum number of busy channels */
volatile int max_busy;
- /* worker name */
- char name[JK_SHM_STR_SIZ+1];
/* route */
char route[JK_SHM_STR_SIZ+1];
/* worker domain */
@@ -88,17 +87,8 @@
volatile jk_uint64_t lb_mult;
/* Current lb value */
volatile jk_uint64_t lb_value;
- int sticky_session;
- int sticky_session_force;
- int recover_wait_time;
- int max_reply_timeouts;
- int retries;
- int lbmethod;
- int lblock;
/* Statistical data */
volatile time_t error_time;
- /* Service transfer rate time */
- volatile time_t last_maintain_time;
/* Number of bytes read from remote */
volatile jk_uint64_t readed;
/* Number of bytes transferred to remote */
@@ -114,7 +104,34 @@
/* Number of client errors */
volatile jk_uint32_t client_errors;
};
-typedef struct jk_shm_worker jk_shm_worker_t;
+typedef struct jk_shm_ajp13_worker jk_shm_ajp13_worker_t;
+
+/** jk shm lb worker record structure */
+struct jk_shm_lb_worker
+{
+ int id;
+ int type;
+ /* worker name */
+ char name[JK_SHM_STR_SIZ+1];
+ /* Sequence counter starting at 0 and increasing
+ * every time we change the config
+ */
+ volatile unsigned int sequence;
+ /* Number of currently busy channels */
+ volatile int busy;
+ /* Maximum number of busy channels */
+ volatile int max_busy;
+ int sticky_session;
+ int sticky_session_force;
+ int recover_wait_time;
+ int max_reply_timeouts;
+ 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;
const char *jk_shm_name(void);
@@ -139,10 +156,15 @@
*/
void *jk_shm_alloc(jk_pool_t *p, size_t size);
-/* allocate shm worker record
+/* allocate shm ajp13 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);
+
+/* allocate shm lb worker record
* If there is no shm present the pool will be used instead
*/
-jk_shm_worker_t *jk_shm_alloc_worker(jk_pool_t *p);
+jk_shm_lb_worker_t *jk_shm_alloc_lb_worker(jk_pool_t *p);
/* Return workers.properties last modified time
*/
Modified: tomcat/connectors/trunk/jk/xdocs/miscellaneous/changelog.xml
URL:
http://svn.apache.org/viewvc/tomcat/connectors/trunk/jk/xdocs/miscellaneous/changelog.xml?rev=609404&r1=609403&r2=609404&view=diff
==============================================================================
--- tomcat/connectors/trunk/jk/xdocs/miscellaneous/changelog.xml (original)
+++ tomcat/connectors/trunk/jk/xdocs/miscellaneous/changelog.xml Sun Jan 6
13:14:08 2008
@@ -44,6 +44,10 @@
<subsection name="Native">
<changelog>
<update>
+ SHM: Use distinct structs for lb and ajp13 in shm.
+ Improves type safety and saves a few bytes. (rjung)
+ </update>
+ <update>
SHM: Remove unused attributes. (rjung)
</update>
<update>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]