You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by rj...@apache.org on 2008/01/10 01:09:48 UTC

svn commit: r610619 - in /tomcat/connectors/trunk/jk/native/common: jk_lb_worker.c jk_lb_worker.h jk_shm.h

Author: rjung
Date: Wed Jan  9 16:09:41 2008
New Revision: 610619

URL: http://svn.apache.org/viewvc?rev=610619&view=rev
Log:
LB sub member dynamic management part 1:
Add attributes to worker_record and extend
shm push and pull from lb to lb sub workers.

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.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=610619&r1=610618&r2=610619&view=diff
==============================================================================
--- tomcat/connectors/trunk/jk/native/common/jk_lb_worker.c (original)
+++ tomcat/connectors/trunk/jk/native/common/jk_lb_worker.c Wed Jan  9 16:09:41 2008
@@ -264,8 +264,12 @@
 }
 
 /* Syncing config values from shm */
-void jk_lb_pull(lb_worker_t * p, jk_logger_t *l) {
+void jk_lb_pull(lb_worker_t * p, jk_logger_t *l)
+{
+    unsigned int i = 0;
+
     JK_TRACE_ENTER(l);
+
     if (JK_IS_DEBUG_LEVEL(l))
         jk_log(l, JK_LOG_DEBUG,
                "syncing mem for lb '%s' from shm",
@@ -278,12 +282,35 @@
     p->lbmethod = p->s->lbmethod;
     p->lblock = p->s->lblock;
     p->sequence = p->s->sequence;
+
+    for (i = 0; i < p->num_of_workers; i++) {
+        worker_record_t *w = &p->lb_workers[i];
+        if (w->sequence != w->s->sequence) {
+            if (JK_IS_DEBUG_LEVEL(l))
+                jk_log(l, JK_LOG_DEBUG,
+                       "syncing mem for member '%s' of lb '%s' from shm",
+                       w->s->name, p->s->name);
+            strncpy(w->route, w->s->route, JK_SHM_STR_SIZ);
+            strncpy(w->domain, w->s->domain, JK_SHM_STR_SIZ);
+            strncpy(w->redirect, w->s->redirect, JK_SHM_STR_SIZ);
+            w->distance = w->s->distance;
+            w->activation = w->s->activation;
+            w->lb_factor = w->s->lb_factor;
+            w->lb_mult = w->s->lb_mult;
+            w->sequence = w->s->sequence;
+        }
+    }
+
     JK_TRACE_EXIT(l);
 }
 
-/* Syncing config values from shm */
-void jk_lb_push(lb_worker_t * p, jk_logger_t *l) {
+/* Syncing config values to shm */
+void jk_lb_push(lb_worker_t * p, jk_logger_t *l)
+{
+    unsigned int i = 0;
+
     JK_TRACE_ENTER(l);
+
     if (JK_IS_DEBUG_LEVEL(l))
         jk_log(l, JK_LOG_DEBUG,
                "syncing shm for lb '%s' from mem",
@@ -296,6 +323,25 @@
     p->s->lbmethod = p->lbmethod;
     p->s->lblock = p->lblock;
     p->s->sequence = p->sequence;
+
+    for (i = 0; i < p->num_of_workers; i++) {
+        worker_record_t *w = &p->lb_workers[i];
+        if (w->sequence != w->s->sequence) {
+            if (JK_IS_DEBUG_LEVEL(l))
+                jk_log(l, JK_LOG_DEBUG,
+                       "syncing shm for member '%s' of lb '%s' from mem",
+                       w->s->name, p->s->name);
+            strncpy(w->s->route, w->route, JK_SHM_STR_SIZ);
+            strncpy(w->s->domain, w->domain, JK_SHM_STR_SIZ);
+            strncpy(w->s->redirect, w->redirect, JK_SHM_STR_SIZ);
+            w->s->distance = w->distance;
+            w->s->activation = w->activation;
+            w->s->lb_factor = w->lb_factor;
+            w->s->lb_mult = w->lb_mult;
+            w->s->sequence = w->sequence;
+        }
+    }
+
     JK_TRACE_EXIT(l);
 }
 
@@ -798,7 +844,7 @@
                         jk_log(l, JK_LOG_DEBUG,
                                "found worker %s (%s) for route %s and partial sessionid %s",
                                rc->s->name, rc->s->route, session_route, sessionid);
-                        JK_TRACE_EXIT(l);
+                    JK_TRACE_EXIT(l);
                     return rc;
                 }
             }
@@ -905,6 +951,11 @@
     /* Set returned error to OK */
     *is_error = JK_HTTP_OK;
 
+    jk_shm_lock();
+    if (p->worker->sequence != p->worker->s->sequence)
+        jk_lb_pull(p->worker, l);
+    jk_shm_unlock();
+
     /* set the recovery post, for LB mode */
     s->reco_buf = jk_b_new(s->pool);
     if (!s->reco_buf) {
@@ -923,11 +974,6 @@
     }
     jk_b_reset(s->reco_buf);
     s->reco_status = RECO_INITED;
-
-    jk_shm_lock();
-    if (p->worker->sequence != p->worker->s->sequence)
-        jk_lb_pull(p->worker, l);
-    jk_shm_unlock();
 
     if (p->worker->sticky_session) {
         /* Use sessionid only if sticky_session is

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=610619&r1=610618&r2=610619&view=diff
==============================================================================
--- tomcat/connectors/trunk/jk/native/common/jk_lb_worker.h (original)
+++ tomcat/connectors/trunk/jk/native/common/jk_lb_worker.h Wed Jan  9 16:09:41 2008
@@ -123,6 +123,25 @@
     jk_worker_t           *w;
     /* Shared memory worker data */
     jk_shm_ajp13_worker_t *s;
+    char         name[JK_SHM_STR_SIZ+1];
+    /* route */
+    char    route[JK_SHM_STR_SIZ+1];
+    /* worker domain */
+    char    domain[JK_SHM_STR_SIZ+1];
+    /* worker redirect route */
+    char    redirect[JK_SHM_STR_SIZ+1];
+    /* worker distance */
+    volatile int distance;
+    /* current activation state (config) of the worker */
+    volatile int activation;
+    /* Current lb factor */
+    volatile int lb_factor;
+    /* Current lb reciprocal factor */
+    volatile jk_uint64_t lb_mult;
+    /* Sequence counter starting at 0 and increasing
+     * every time we change the config
+     */
+    volatile unsigned int sequence;
 };
 typedef struct worker_record worker_record_t;
 

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=610619&r1=610618&r2=610619&view=diff
==============================================================================
--- tomcat/connectors/trunk/jk/native/common/jk_shm.h (original)
+++ tomcat/connectors/trunk/jk/native/common/jk_shm.h Wed Jan  9 16:09:41 2008
@@ -65,6 +65,10 @@
     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 */



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org