You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by mt...@apache.org on 2011/06/18 17:14:10 UTC

svn commit: r1137200 - in /tomcat/jk/trunk/native/common: jk_ajp_common.c jk_ajp_common.h jk_lb_worker.c

Author: mturk
Date: Sat Jun 18 15:14:10 2011
New Revision: 1137200

URL: http://svn.apache.org/viewvc?rev=1137200&view=rev
Log:
Check the workers marked as BUSY if they are really busy. This fixes the cases where worker marked as busy stays in that state forever

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

Modified: tomcat/jk/trunk/native/common/jk_ajp_common.c
URL: http://svn.apache.org/viewvc/tomcat/jk/trunk/native/common/jk_ajp_common.c?rev=1137200&r1=1137199&r2=1137200&view=diff
==============================================================================
--- tomcat/jk/trunk/native/common/jk_ajp_common.c (original)
+++ tomcat/jk/trunk/native/common/jk_ajp_common.c Sat Jun 18 15:14:10 2011
@@ -3345,3 +3345,39 @@ int JK_METHOD ajp_maintain(jk_worker_t *
     JK_TRACE_EXIT(l);
     return JK_FALSE;
 }
+
+int ajp_has_endpoint(jk_worker_t *pThis,
+                     jk_logger_t *l)
+{
+    JK_TRACE_ENTER(l);
+
+    if (pThis && pThis->worker_private) {
+        ajp_worker_t *aw = pThis->worker_private;
+        int rc;
+
+        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]) {
+                    JK_LEAVE_CS(&aw->cs, rc);
+                    return JK_TRUE;
+                }
+            }
+            JK_LEAVE_CS(&aw->cs, rc);
+        }
+        else {
+            jk_log(l, JK_LOG_ERROR,
+                    "locking thread (errno=%d)", errno);
+            JK_TRACE_EXIT(l);
+            return JK_FALSE;
+        }
+    }
+    else {
+        JK_LOG_NULL_PARAMS(l);
+    }
+
+    JK_TRACE_EXIT(l);
+    return JK_FALSE;
+}

Modified: tomcat/jk/trunk/native/common/jk_ajp_common.h
URL: http://svn.apache.org/viewvc/tomcat/jk/trunk/native/common/jk_ajp_common.h?rev=1137200&r1=1137199&r2=1137200&view=diff
==============================================================================
--- tomcat/jk/trunk/native/common/jk_ajp_common.h (original)
+++ tomcat/jk/trunk/native/common/jk_ajp_common.h Sat Jun 18 15:14:10 2011
@@ -359,7 +359,7 @@ struct ajp_worker
 
     int retry_interval;            /*  Number of milliseconds to sleep before doing a retry */
 
-    /* 
+    /*
      * HTTP status that will cause failover (0 means disabled)
      */
      unsigned int http_status_fail_num;
@@ -458,6 +458,8 @@ int JK_METHOD ajp_maintain(jk_worker_t *
 
 int jk_ajp_get_cping_mode(const char *m, int def);
 
+int ajp_has_endpoint(jk_worker_t *pThis, jk_logger_t *l);
+
 #ifdef __cplusplus
 }
 #endif                          /* __cplusplus */

Modified: tomcat/jk/trunk/native/common/jk_lb_worker.c
URL: http://svn.apache.org/viewvc/tomcat/jk/trunk/native/common/jk_lb_worker.c?rev=1137200&r1=1137199&r2=1137200&view=diff
==============================================================================
--- tomcat/jk/trunk/native/common/jk_lb_worker.c (original)
+++ tomcat/jk/trunk/native/common/jk_lb_worker.c Sat Jun 18 15:14:10 2011
@@ -1085,8 +1085,18 @@ static int JK_METHOD service(jk_endpoint
     if (p->worker->sequence != p->worker->s->h.sequence)
         jk_lb_pull(p->worker, JK_FALSE, l);
     for (i = 0; i < num_of_workers; i++) {
+        lb_sub_worker_t *rec = &(p->worker->lb_workers[i]);
+        if (rec->s->state == JK_LB_STATE_BUSY) {
+            if (ajp_has_endpoint(rec->worker, l)) {
+                if (JK_IS_DEBUG_LEVEL(l))
+                    jk_log(l, JK_LOG_DEBUG,
+                           "worker %s busy count fixed",
+                           rec->name);
+                rec->s->state = JK_LB_STATE_OK;
+            }
+        }
         /* Copy the shared state info */
-        p->states[i] = p->worker->lb_workers[i].s->state;
+        p->states[i] = rec->s->state;
     }
 
     /* set the recovery post, for LB mode */



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