tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rj...@apache.org
Subject svn commit: r610561 - in /tomcat/connectors/trunk/jk: native/common/jk_lb_worker.c native/common/jk_lb_worker.h xdocs/miscellaneous/changelog.xml
Date Wed, 09 Jan 2008 20:59:49 GMT
Author: rjung
Date: Wed Jan  9 12:59:01 2008
New Revision: 610561

URL: http://svn.apache.org/viewvc?rev=610561&view=rev
Log:
Refactor "route" return value from LB to httpd note JK_WORKER_ROUTE.

1) Our code always returned the worker route, except when the worker
was chosen via the domain. Then it returns the domain name.
2) We used a member of the worker_record, as an intermediate store,
but the worker_record is not thread safe, only the service record is.

So we only need to return the information, if the balancer used the
domain to find the worker and set the service route to the domain
in this case, otherwise to the worker route.
Use an int pointer argument to return the info and remove the
worker_record member "r".

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/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=610561&r1=610560&r2=610561&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 12:59:01 2008
@@ -586,7 +586,6 @@
     for (i = 0; i < p->num_of_workers; i++) {
         if (strcmp(p->lb_workers[i].s->route, name) == 0) {
             rc = &p->lb_workers[i];
-            rc->r = rc->s->route;
             break;
         }
     }
@@ -623,10 +622,6 @@
         }
     }
 
-    if (candidate) {
-        candidate->r = candidate->s->domain;
-    }
-
     return candidate;
 }
 
@@ -668,6 +663,7 @@
 
 static worker_record_t *find_bysession_route(lb_worker_t *p,
                                              const char *name,
+                                             int *route_is_domain,
                                              jk_logger_t *l)
 {
     int uses_domain  = 0;
@@ -677,6 +673,7 @@
     if (!candidate) {
         uses_domain = 1;
         candidate = find_best_bydomain(p, name, l);
+        *route_is_domain = JK_TRUE;
     }
     if (candidate) {
         if (!JK_WORKER_USABLE_STICKY(candidate->s)) {
@@ -688,11 +685,13 @@
              */
             if (p->sticky_session_force)
                 candidate = NULL;
-            else if (*candidate->s->redirect)
+            else if (*candidate->s->redirect) {
                 candidate = find_by_session(p, candidate->s->redirect, l);
+                *route_is_domain = JK_FALSE;
+            }
             else if (*candidate->s->domain && !uses_domain) {
-                uses_domain = 1;
                 candidate = find_best_bydomain(p, candidate->s->domain, l);
+                *route_is_domain = JK_TRUE;
             }
             if (candidate && !JK_WORKER_USABLE_STICKY(candidate->s))
                 candidate = NULL;
@@ -702,6 +701,7 @@
 }
 
 static worker_record_t *find_failover_worker(lb_worker_t * p,
+                                             int *route_is_domain,
                                              jk_logger_t *l)
 {
     worker_record_t *rc = NULL;
@@ -715,27 +715,26 @@
         }
     }
     if (redirect)
-        rc = find_bysession_route(p, redirect, l);
+        rc = find_bysession_route(p, redirect, route_is_domain, l);
     return rc;
 }
 
 static worker_record_t *find_best_worker(lb_worker_t * p,
+                                         int *route_is_domain,
                                          jk_logger_t *l)
 {
     worker_record_t *rc = NULL;
 
     rc = find_best_byvalue(p, l);
     /* By default use worker route as session route */
-    if (rc)
-        rc->r = rc->s->route;
-    else
-        rc = find_failover_worker(p, l);
+    if (!rc)
+        rc = find_failover_worker(p, route_is_domain, l);
     return rc;
 }
 
 static worker_record_t *get_most_suitable_worker(lb_worker_t * p,
                                                  char *sessionid,
-                                                 jk_ws_service_t *s,
+                                                 int *route_is_domain,
                                                  jk_logger_t *l)
 {
     worker_record_t *rc = NULL;
@@ -748,7 +747,6 @@
          */
         if (JK_WORKER_USABLE_STICKY(p->lb_workers[0].s)) {
             if (p->lb_workers[0].s->activation != JK_LB_ACTIVATION_DISABLED) {
-                p->lb_workers[0].r = p->lb_workers[0].s->route;
                 JK_TRACE_EXIT(l);
                 return p->lb_workers;
             }
@@ -789,7 +787,7 @@
                            session_route);
 
                 /* We have a session route. Whow! */
-                rc = find_bysession_route(p, session_route, l);
+                rc = find_bysession_route(p, session_route, route_is_domain, l);
                 if (rc) {
                     if (p->lblock == JK_LB_LOCK_PESSIMISTIC)
                         jk_shm_unlock();
@@ -821,7 +819,7 @@
             return NULL;
         }
     }
-    rc = find_best_worker(p, l);
+    rc = find_best_worker(p, route_is_domain, l);
     if (p->lblock == JK_LB_LOCK_PESSIMISTIC)
         jk_shm_unlock();
     else {
@@ -943,8 +941,9 @@
                p->worker->sticky_session, sessionid ? sessionid : "empty");
 
     while (attempt <= num_of_workers && recoverable == JK_TRUE) {
+        int route_is_domain = JK_FALSE;
         worker_record_t *rec =
-            get_most_suitable_worker(p->worker, sessionid, s, l);
+            get_most_suitable_worker(p->worker, sessionid, &route_is_domain, l);
         rc = JK_FALSE;
         *is_error = JK_HTTP_SERVER_BUSY;
         /* Do not reuse previous worker, because
@@ -956,7 +955,10 @@
             jk_endpoint_t *end = NULL;
             int retry = 0;
             int retry_wait = JK_LB_MIN_RETRY_WAIT;
-            s->route = rec->r;
+            if (route_is_domain == JK_FALSE)
+                s->route = rec->s->route;
+            else
+                s->route = rec->s->domain;
             prec = rec;
 
             if (JK_IS_DEBUG_LEVEL(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=610561&r1=610560&r2=610561&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 12:59:01 2008
@@ -123,8 +123,6 @@
     jk_worker_t           *w;
     /* Shared memory worker data */
     jk_shm_ajp13_worker_t *s;
-    /* Current route. Can be name or domain */
-    const char            *r;
 };
 typedef struct worker_record worker_record_t;
 

Modified: tomcat/connectors/trunk/jk/xdocs/miscellaneous/changelog.xml
URL: http://svn.apache.org/viewvc/tomcat/connectors/trunk/jk/xdocs/miscellaneous/changelog.xml?rev=610561&r1=610560&r2=610561&view=diff
==============================================================================
--- tomcat/connectors/trunk/jk/xdocs/miscellaneous/changelog.xml (original)
+++ tomcat/connectors/trunk/jk/xdocs/miscellaneous/changelog.xml Wed Jan  9 12:59:01 2008
@@ -44,6 +44,10 @@
   <subsection name="Native">
     <changelog>
       <update>
+        LB: Refactor "route" return for httpd note. Don't use a
+        member of the worker_record, because that's not thread safe. (rjung)
+      </update>
+      <update>
         Common: Refactor "retries", remove from service and jk_worker,
         move into ajp worker instead. (rjung)
       </update>



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


Mime
View raw message