tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mt...@apache.org
Subject svn commit: r701758 - in /tomcat/connectors/trunk/jk/native/common: jk_ajp_common.c jk_lb_worker.c
Date Sun, 05 Oct 2008 08:13:50 GMT
Author: mturk
Date: Sun Oct  5 01:13:50 2008
New Revision: 701758

URL: http://svn.apache.org/viewvc?rev=701758&view=rev
Log:
For getting the free endpoint from the worker in load balancer, use that workers retries/retry_interval
setting.

Modified:
    tomcat/connectors/trunk/jk/native/common/jk_ajp_common.c
    tomcat/connectors/trunk/jk/native/common/jk_lb_worker.c

Modified: tomcat/connectors/trunk/jk/native/common/jk_ajp_common.c
URL: http://svn.apache.org/viewvc/tomcat/connectors/trunk/jk/native/common/jk_ajp_common.c?rev=701758&r1=701757&r2=701758&view=diff
==============================================================================
--- tomcat/connectors/trunk/jk/native/common/jk_ajp_common.c (original)
+++ tomcat/connectors/trunk/jk/native/common/jk_ajp_common.c Sun Oct  5 01:13:50 2008
@@ -2212,6 +2212,11 @@
                        "retry %d, sleeping for %d ms before retrying",
                        i, retry_interval);
             jk_sleep(retry_interval);
+            /* Pull shared memory if something changed during sleep */
+            jk_shm_lock();
+            if (aw->sequence != aw->s->h.sequence)
+                jk_ajp_pull(aw, l);
+            jk_shm_unlock();
         }
         /*
          * We're using op->request which hold initial request

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=701758&r1=701757&r2=701758&view=diff
==============================================================================
--- tomcat/connectors/trunk/jk/native/common/jk_lb_worker.c (original)
+++ tomcat/connectors/trunk/jk/native/common/jk_lb_worker.c Sun Oct  5 01:13:50 2008
@@ -1094,8 +1094,8 @@
             int is_service_error = JK_HTTP_OK;
             ajp_worker_t *aw = (ajp_worker_t *)rec->worker->worker_private;
             jk_endpoint_t *end = NULL;
-            int retry = 0;
-            int retry_interval = JK_LB_MIN_RETRY_INTERVAL;
+            int ge_retry = 0;
+            int ge_retry_interval = aw->retry_interval;
 
             if (!s->route)
                 s->route = rec->route;
@@ -1115,23 +1115,20 @@
             if (p->worker->lblock == JK_LB_LOCK_PESSIMISTIC)
                 jk_shm_unlock();
 
-            while ((!(r=rec->worker->get_endpoint(rec->worker, &end, l)) ||
!end) && (retry < p->worker->retries)) {
-                retry++;
-                retry_interval *=2;
-
-                if (p->worker->lblock == JK_LB_LOCK_PESSIMISTIC)
-                    jk_shm_lock();
-                if (retry_interval > JK_LB_MAX_RETRY_INTERVAL)
-                    retry_interval = JK_LB_MAX_RETRY_INTERVAL;
-                if (p->worker->lblock == JK_LB_LOCK_PESSIMISTIC)
-                    jk_shm_unlock();
-
+            while ((!(r=rec->worker->get_endpoint(rec->worker, &end, l)) ||
!end) &&
+                        (ge_retry < aw->retries)) {
+                ge_retry++;
                 if (JK_IS_DEBUG_LEVEL(l))
                     jk_log(l, JK_LOG_DEBUG,
                            "could not get free endpoint for worker"
                            " (retry %d, sleeping for %d ms)",
-                           retry, retry_interval);
-                jk_sleep(retry_interval);
+                           ge_retry, ge_retry_interval);
+                jk_sleep(ge_retry_interval);
+                /* Pull shared memory if something changed during sleep */
+                jk_shm_lock();
+                if (p->worker->sequence != p->worker->s->h.sequence)
+                    jk_lb_pull(p->worker, l);
+                jk_shm_unlock();
             }
             if (!r || !end) {
                 /* If we can not get the endpoint
@@ -1330,13 +1327,13 @@
                     rec->s->error_time = time(NULL);
                     rc = JK_FALSE;
                 }
+                if (p->worker->lblock == JK_LB_LOCK_PESSIMISTIC)
+                    jk_shm_unlock();
                 if (p->states[rec->i] == JK_LB_STATE_ERROR)
                     jk_log(l, JK_LOG_INFO,
                            "service failed, worker %s is in %serror state",
                            rec->name,
                            rec->s->state == JK_LB_STATE_ERROR ? "" : "local ");
-                if (p->worker->lblock == JK_LB_LOCK_PESSIMISTIC)
-                    jk_shm_unlock();
             }
             if (recoverable == JK_TRUE) {
                 /*



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


Mime
View raw message