tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mt...@apache.org
Subject svn commit: r702376 - in /tomcat/connectors/trunk/jk/native/common: jk_ajp_common.c jk_lb_worker.c
Date Tue, 07 Oct 2008 08:01:27 GMT
Author: mturk
Date: Tue Oct  7 01:01:27 2008
New Revision: 702376

URL: http://svn.apache.org/viewvc?rev=702376&view=rev
Log:
Move get_endpoint retries to the get_endpoint function

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=702376&r1=702375&r2=702376&view=diff
==============================================================================
--- tomcat/connectors/trunk/jk/native/common/jk_ajp_common.c (original)
+++ tomcat/connectors/trunk/jk/native/common/jk_ajp_common.c Tue Oct  7 01:01:27 2008
@@ -2815,62 +2815,70 @@
     if (pThis && pThis->worker_private && je) {
         ajp_worker_t *aw = pThis->worker_private;
         ajp_endpoint_t *ae = NULL;
-        time_t now = 0;
         int rc;
-        /* Obtain current time only if needed */
-        if (aw->cache_timeout > 0)
-            now = time(NULL);
+        int retry = 0;
+
         *je = NULL;
+        /* Obtain current time only if needed */
+        while (retry < aw->retries) {
 
-        JK_ENTER_CS(&aw->cs, rc);
-        if (rc) {
-            unsigned int slot;
-            /* Try to find connected socket cache entry */
-            for (slot = 0; slot < aw->ep_cache_sz; slot++) {
-                if (aw->ep_cache[slot] &&
-                    IS_VALID_SOCKET(aw->ep_cache[slot]->sd)) {
-                    ae = aw->ep_cache[slot];
-                    aw->ep_cache[slot] = NULL;
-                    break;
-                }
-            }
-            if (!ae) {
-                /* No connected cache entry found.
-                 * Use the first free one.
-                 */
+            JK_ENTER_CS(&aw->cs, rc);
+            if (rc) {
+                unsigned int slot;
+                /* Try to find connected socket cache entry */
                 for (slot = 0; slot < aw->ep_cache_sz; slot++) {
-                    if (aw->ep_cache[slot]) {
+                    if (aw->ep_cache[slot] &&
+                        IS_VALID_SOCKET(aw->ep_cache[slot]->sd)) {
                         ae = aw->ep_cache[slot];
                         aw->ep_cache[slot] = NULL;
                         break;
                     }
                 }
-            }
-            JK_LEAVE_CS(&aw->cs, rc);
-            if (ae) {
-                ae->last_access = now;
-                *je = &ae->endpoint;
-                if (JK_IS_DEBUG_LEVEL(l))
-                    jk_log(l, JK_LOG_DEBUG,
-                           "acquired connection pool slot=%u",
-                           slot);
-                JK_TRACE_EXIT(l);
-                return JK_TRUE;
+                if (!ae) {
+                    /* No connected cache entry found.
+                     * Use the first free one.
+                     */
+                    for (slot = 0; slot < aw->ep_cache_sz; slot++) {
+                        if (aw->ep_cache[slot]) {
+                            ae = aw->ep_cache[slot];
+                            aw->ep_cache[slot] = NULL;
+                            break;
+                        }
+                    }
+                }
+                JK_LEAVE_CS(&aw->cs, rc);
+                if (ae) {
+                    if (aw->cache_timeout > 0)
+                        ae->last_access = time(NULL);
+                    *je = &ae->endpoint;
+                    if (JK_IS_DEBUG_LEVEL(l))
+                        jk_log(l, JK_LOG_DEBUG,
+                               "acquired connection pool slot=%u",
+                               slot);
+                    JK_TRACE_EXIT(l);
+                    return JK_TRUE;
+                }
+                else {
+                    retry++;
+                    if (JK_IS_DEBUG_LEVEL(l))
+                        jk_log(l, JK_LOG_DEBUG,
+                               "could not get free endpoint for worker %s"
+                               " (retry %d, sleeping for %d ms)",
+                               aw->name, retry, aw->retry_interval);
+                    jk_sleep(aw->retry_interval);
+                }
             }
             else {
-                jk_log(l, JK_LOG_WARNING,
-                        "Unable to get the free endpoint for worker %s from %u slots",
-                        aw->name, aw->ep_cache_sz);
-            }
-        }
-        else {
-           jk_log(l, JK_LOG_ERROR,
-                  "locking thread (errno=%d)",
-                  errno);
-            JK_TRACE_EXIT(l);
-            return JK_FALSE;
+               jk_log(l, JK_LOG_ERROR,
+                      "locking thread (errno=%d)", errno);
+                JK_TRACE_EXIT(l);
+                return JK_FALSE;
 
+            }
         }
+        jk_log(l, JK_LOG_WARNING,
+                "Unable to get the free endpoint for worker %s from %u slots",
+                aw->name, aw->ep_cache_sz);
     }
     else {
         JK_LOG_NULL_PARAMS(l);

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=702376&r1=702375&r2=702376&view=diff
==============================================================================
--- tomcat/connectors/trunk/jk/native/common/jk_lb_worker.c (original)
+++ tomcat/connectors/trunk/jk/native/common/jk_lb_worker.c Tue Oct  7 01:01:27 2008
@@ -1119,8 +1119,6 @@
             int is_service_error = JK_HTTP_OK;
             ajp_worker_t *aw = (ajp_worker_t *)rec->worker->worker_private;
             jk_endpoint_t *end = NULL;
-            int ge_retry = 0;
-            int ge_retry_interval = aw->retry_interval;
 
             if (!s->route)
                 s->route = rec->route;
@@ -1140,21 +1138,7 @@
             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)",
-                           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();
-            }
+            r = rec->worker->get_endpoint(rec->worker, &end, l);
             if (!r || !end) {
                 /* If we can not get the endpoint
                  * mark the worker as busy rather then
@@ -1171,7 +1155,7 @@
                     jk_shm_unlock();
                 jk_log(l, JK_LOG_INFO,
                        "could not get free endpoint for worker %s (%d retries)",
-                       rec->name, ge_retry);
+                       rec->name, retry);
             }
             else {
                 int service_stat = JK_UNSET;



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


Mime
View raw message