tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mt...@apache.org
Subject 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
Date Sat, 24 Jun 2006 10:44:35 GMT
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


Mime
View raw message