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 2006/06/24 12:44:35 UTC

svn commit: r416897 - in /tomcat/connectors/trunk/jk/native/common: jk_ajp_common.c jk_ajp_common.h jk_lb_worker.c jk_service.h jk_worker.c

Author: mturk
Date: Sat Jun 24 03:44:34 2006
New Revision: 416897

URL: http://svn.apache.org/viewvc?rev=416897&view=rev
Log:
Instead calling time(NULL), use it as a function
parameter.

Modified:
    tomcat/connectors/trunk/jk/native/common/jk_ajp_common.c
    tomcat/connectors/trunk/jk/native/common/jk_ajp_common.h
    tomcat/connectors/trunk/jk/native/common/jk_lb_worker.c
    tomcat/connectors/trunk/jk/native/common/jk_service.h
    tomcat/connectors/trunk/jk/native/common/jk_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=416897&r1=416896&r2=416897&view=diff
==============================================================================
--- tomcat/connectors/trunk/jk/native/common/jk_ajp_common.c (original)
+++ tomcat/connectors/trunk/jk/native/common/jk_ajp_common.c Sat Jun 24 03:44:34 2006
@@ -2173,18 +2173,15 @@
     return JK_FALSE;
 }
 
-int JK_METHOD ajp_maintain(jk_worker_t *pThis, jk_logger_t *l)
+int JK_METHOD ajp_maintain(jk_worker_t *pThis, time_t now, jk_logger_t *l)
 {
     JK_TRACE_ENTER(l);
 
     if (pThis && pThis->worker_private) {
         ajp_worker_t *aw = pThis->worker_private;
-        time_t now;
         int rc;
         /* Obtain current time only if needed */
-        if (aw->cache_timeout > 0)
-            now = time(NULL);
-        else {
+        if (aw->cache_timeout < 1) {
             /* Nothing to do. */
             JK_TRACE_EXIT(l);
             return JK_TRUE;

Modified: tomcat/connectors/trunk/jk/native/common/jk_ajp_common.h
URL: http://svn.apache.org/viewvc/tomcat/connectors/trunk/jk/native/common/jk_ajp_common.h?rev=416897&r1=416896&r2=416897&view=diff
==============================================================================
--- tomcat/connectors/trunk/jk/native/common/jk_ajp_common.h (original)
+++ tomcat/connectors/trunk/jk/native/common/jk_ajp_common.h Sat Jun 24 03:44:34 2006
@@ -355,7 +355,7 @@
 int ajp_connection_tcp_get_message(ajp_endpoint_t * ae,
                                    jk_msg_buf_t *msg, jk_logger_t *l);
 
-int JK_METHOD ajp_maintain(jk_worker_t *pThis, jk_logger_t *l);
+int JK_METHOD ajp_maintain(jk_worker_t *pThis, time_t now, jk_logger_t *l);
 
 #ifdef __cplusplus
 }

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=416897&r1=416896&r2=416897&view=diff
==============================================================================
--- tomcat/connectors/trunk/jk/native/common/jk_lb_worker.c (original)
+++ tomcat/connectors/trunk/jk/native/common/jk_lb_worker.c Sat Jun 24 03:44:34 2006
@@ -226,10 +226,10 @@
  */
 static void recover_workers(lb_worker_t *p,
                             jk_uint64_t curmax,
+                            time_t now,
                             jk_logger_t *l)
 {
     unsigned int i;
-    time_t now = time(NULL);
     int elapsed;
     worker_record_t *w = NULL;
     JK_TRACE_ENTER(l);
@@ -270,6 +270,7 @@
 {
     unsigned int i;
     jk_uint64_t curmax = 0;
+
     JK_TRACE_ENTER(l);
     if (p->lbmethod != JK_LB_BYBUSYNESS) {
         for (i = 0; i < p->num_of_workers; i++) {
@@ -283,32 +284,32 @@
     return curmax;
 }
 
-static int JK_METHOD maintain_workers(jk_worker_t *p, jk_logger_t *l)
+static int JK_METHOD maintain_workers(jk_worker_t *p, time_t now, jk_logger_t *l)
 {
     unsigned int i = 0;
     jk_uint64_t curmax = 0;
     long delta;
-    time_t now = time(NULL);
-    JK_TRACE_ENTER(l);
+    now = time(NULL);
 
+    JK_TRACE_ENTER(l);
     if (p && p->worker_private) {
         lb_worker_t *lb = (lb_worker_t *)p->worker_private;
 
         for (i = 0; i < lb->num_of_workers; i++) {
             if (lb->lb_workers[i].w->maintain) {
-                lb->lb_workers[i].w->maintain(lb->lb_workers[i].w, l);
+                lb->lb_workers[i].w->maintain(lb->lb_workers[i].w, now, l);
             }
         }
 
         jk_shm_lock();
 
-/* Now we check for global maintenance (once for all processes).
- * Checking workers for recovery and applying decay to the
- * load values should not be done by each process individually.
- * Therefore we globally sync and we use a global timestamp.
- * Since it's possible that we come here a few milliseconds
- * before the interval has passed, we allow a little tolerance.
- */
+        /* Now we check for global maintenance (once for all processes).
+         * Checking workers for recovery and applying decay to the
+         * load values should not be done by each process individually.
+         * Therefore we globally sync and we use a global timestamp.
+         * Since it's possible that we come here a few milliseconds
+         * before the interval has passed, we allow a little tolerance.
+         */
         delta = (long)difftime(now, lb->s->last_maintain_time) + JK_LB_MAINTAIN_TOLERANCE;
         if (delta >= lb->maintain_time) {
             lb->s->last_maintain_time = now;
@@ -317,7 +318,7 @@
                        "decay with 2^%d",
                        JK_LB_DECAY_MULT * delta / lb->maintain_time);
             curmax = decay_load(lb, JK_LB_DECAY_MULT * delta / lb->maintain_time, l);
-            recover_workers(lb, curmax, l);
+            recover_workers(lb, curmax, now, l);
         }
 
         jk_shm_unlock();

Modified: tomcat/connectors/trunk/jk/native/common/jk_service.h
URL: http://svn.apache.org/viewvc/tomcat/connectors/trunk/jk/native/common/jk_service.h?rev=416897&r1=416896&r2=416897&view=diff
==============================================================================
--- tomcat/connectors/trunk/jk/native/common/jk_service.h (original)
+++ tomcat/connectors/trunk/jk/native/common/jk_service.h Sat Jun 24 03:44:34 2006
@@ -425,7 +425,7 @@
     /*
      * Maintain this worker.
      */
-    int (JK_METHOD * maintain) (jk_worker_t *w, jk_logger_t *l);
+    int (JK_METHOD * maintain) (jk_worker_t *w, time_t now, jk_logger_t *l);
 
 };
 

Modified: tomcat/connectors/trunk/jk/native/common/jk_worker.c
URL: http://svn.apache.org/viewvc/tomcat/connectors/trunk/jk/native/common/jk_worker.c?rev=416897&r1=416896&r2=416897&view=diff
==============================================================================
--- tomcat/connectors/trunk/jk/native/common/jk_worker.c (original)
+++ tomcat/connectors/trunk/jk/native/common/jk_worker.c Sat Jun 24 03:44:34 2006
@@ -301,7 +301,7 @@
                         jk_log(l, JK_LOG_DEBUG,
                                "Maintaining worker %s",
                                jk_map_name_at(worker_map, i));
-                    w->maintain(w, l);
+                    w->maintain(w, now, l);
                 }
             }
         }



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


jk/native/common/jk_ajp_common.c: Buglet concerning ep_mincache_sz

Posted by Rainer Jung <ra...@kippdata.de>.
Hi Mladen,

In jk/native/common/jk_ajp_common.c: Are you able to convince me, that 
this condition is correct:

  2210                  if (n > aw->ep_mincache_sz) {
  2211                      if (JK_IS_DEBUG_LEVEL(l)) {
  2212                          jk_log(l, JK_LOG_DEBUG,
  2213                          "reached pool min size %u from %u cache 
slots",
  2214                          aw->ep_mincache_sz, aw->ep_cache_sz);
  2215                      }
  2216                      break;
  2217                  }

Variable n counts how many connections we closed during this run of 
maintain and ep_mincache_sz as I understand it, should be the amount of 
connections established (or actually being used).

In order to determine the number of connections we are allowed to close 
we need to know, how many are already closed (or the complement = 
established).

So we must either iterate through the cache two times (first counting 
established or used connections) and then actually closing.
Or we add the number of established connections as a member to the 
worker and only close connections if established > ep_mincache_sz.

Am I wrong?


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


Re: svn commit: r416897 - in /tomcat/connectors/trunk/jk/native/common: jk_ajp_common.c jk_ajp_common.h jk_lb_worker.c jk_service.h jk_worker.c

Posted by Mladen Turk <mt...@apache.org>.
Rainer Jung wrote:
>>  
>> -static int JK_METHOD maintain_workers(jk_worker_t *p, jk_logger_t *l)
>> +static int JK_METHOD maintain_workers(jk_worker_t *p, time_t now, 
>> jk_logger_t *l)
>>  {
>>      unsigned int i = 0;
>>      jk_uint64_t curmax = 0;
>>      long delta;
>> -    time_t now = time(NULL);
>> -    JK_TRACE_ENTER(l);
>> +    now = time(NULL);
>>   
> Shouldn't we also drop this last line?
>

Yes we should. That was the point of having a single
call for time(NULL). Since its resolution is in seconds,
IMHO we are safe with any CPU > 1 MHz :)

Regards,
Mladen.

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


Re: svn commit: r416897 - in /tomcat/connectors/trunk/jk/native/common: jk_ajp_common.c jk_ajp_common.h jk_lb_worker.c jk_service.h jk_worker.c

Posted by Rainer Jung <ra...@kippdata.de>.
mturk@apache.org schrieb:
> Author: mturk
> Date: Sat Jun 24 03:44:34 2006
> New Revision: 416897
>
> URL: http://svn.apache.org/viewvc?rev=416897&view=rev
> Log:
> Instead calling time(NULL), use it as a function
> parameter.
>   
> Modified: tomcat/connectors/trunk/jk/native/common/jk_lb_worker.c
>
> @@ -283,32 +284,32 @@
>      return curmax;
>  }
>  
> -static int JK_METHOD maintain_workers(jk_worker_t *p, jk_logger_t *l)
> +static int JK_METHOD maintain_workers(jk_worker_t *p, time_t now, jk_logger_t *l)
>  {
>      unsigned int i = 0;
>      jk_uint64_t curmax = 0;
>      long delta;
> -    time_t now = time(NULL);
> -    JK_TRACE_ENTER(l);
> +    now = time(NULL);
>   
Shouldn't we also drop this last line?


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