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 2008/09/22 10:19:44 UTC

svn commit: r697697 - in /tomcat/connectors/trunk/jk: native/common/jk_ajp_common.c native/common/jk_ajp_common.h native/common/jk_util.c native/common/jk_util.h xdocs/miscellaneous/changelog.xml xdocs/reference/workers.xml

Author: mturk
Date: Mon Sep 22 01:19:44 2008
New Revision: 697697

URL: http://svn.apache.org/viewvc?rev=697697&view=rev
Log:
Add ping_mode directive

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_util.c
    tomcat/connectors/trunk/jk/native/common/jk_util.h
    tomcat/connectors/trunk/jk/xdocs/miscellaneous/changelog.xml
    tomcat/connectors/trunk/jk/xdocs/reference/workers.xml

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=697697&r1=697696&r2=697697&view=diff
==============================================================================
--- tomcat/connectors/trunk/jk/native/common/jk_ajp_common.c (original)
+++ tomcat/connectors/trunk/jk/native/common/jk_ajp_common.c Mon Sep 22 01:19:44 2008
@@ -362,7 +362,22 @@
         return JK_AJP_STATE_DEF;
 }
 
-
+int jk_ajp_get_cping_mode(const char *m, int def)
+{
+    int mv = def;
+    if (!m)
+        return mv;
+    while (*m != '\0') {
+        if (*m == 'C' || *m == 'c')
+            mv |= AJP_CPING_CONNECT;
+        else if (*m == 'P' || *m == 'p')
+            mv |= AJP_CPING_PREPOST;
+        else if (*m == 'I' || *m == 'i')
+            mv |= AJP_CPING_INTERVAL;
+        m++;
+    }
+    return mv;
+}
 
 /*
  * Message structure
@@ -2477,23 +2492,37 @@
                                         AJP_DEF_CACHE_TIMEOUT);
 
         p->ping_timeout =
-            jk_get_worker_ping_timeout(props, p->name, 0);
-
+            jk_get_worker_ping_timeout(props, p->name,
+                                       AJP_DEF_PING_TIMEOUT);
+        p->ping_mode =
+            jk_get_worker_ping_mode(props, p->name,
+                                    AJP_CPING_NONE);
+        
         p->connect_timeout =
             jk_get_worker_connect_timeout(props, p->name,
-                                          p->ping_timeout);
+                                          AJP_DEF_CONNECT_TIMEOUT);
 
         p->prepost_timeout =
             jk_get_worker_prepost_timeout(props, p->name,
-                                          p->ping_timeout);
+                                          AJP_DEF_PREPOST_TIMEOUT);
+        if ((p->ping_mode & AJP_CPING_CONNECT) &&
+             p->connect_timeout == AJP_DEF_CONNECT_TIMEOUT)
+            p->connect_timeout = p->ping_timeout;
+
+        if ((p->ping_mode & AJP_CPING_PREPOST) &&
+             p->prepost_timeout == AJP_DEF_PREPOST_TIMEOUT)
+            p->prepost_timeout = p->ping_timeout;
+
+        p->conn_ping_interval =
+            jk_get_worker_conn_ping_interval(props, p->name, 0);
+        if ((p->ping_mode & AJP_CPING_PREPOST) &&
+            p->conn_ping_interval == 0)
+            p->conn_ping_interval = p->ping_timeout / 10;
 
         p->reply_timeout =
             jk_get_worker_reply_timeout(props, p->name,
                                         AJP_DEF_REPLY_TIMEOUT);
 
-        p->conn_ping_interval =
-            jk_get_worker_conn_ping_interval(props, p->name, 0);
-
         p->recovery_opts =
             jk_get_worker_recovery_opts(props, p->name,
                                         AJP_DEF_RECOVERY_OPTS);

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=697697&r1=697696&r2=697697&view=diff
==============================================================================
--- tomcat/connectors/trunk/jk/native/common/jk_ajp_common.h (original)
+++ tomcat/connectors/trunk/jk/native/common/jk_ajp_common.h Mon Sep 22 01:19:44 2008
@@ -212,7 +212,14 @@
 #define AJP_DEF_REPLY_TIMEOUT     (0)   /* NO REPLY TIMEOUT                        */
 #define AJP_DEF_PREPOST_TIMEOUT   (0)   /* NO PREPOST TIMEOUT => NO CPING/CPONG    */
 #define AJP_DEF_RECOVERY_OPTS     (0)   /* NO RECOVERY / NO    */
-#define AJP_DEF_SOCKET_TIMEOUT    (0)  /* No timeout */
+#define AJP_DEF_SOCKET_TIMEOUT    (0)   /* No timeout */
+#define AJP_DEF_PING_TIMEOUT      (10000)  /* Default CPING/CPONG timeout (10 seconds) */
+
+#define AJP_CPING_NONE            (0)   /* Do not send cping packets */
+#define AJP_CPING_CONNECT         (1)   /* Send cping on fresh connection */
+#define AJP_CPING_PREPOST         (2)   /* Send cping before sending request */
+#define AJP_CPING_INTERVAL        (4)   /* Send cping on regular intervals */
+
 
 #define RECOVER_ABORT_IF_TCGETREQUEST    0x0001 /* DON'T RECOVER IF TOMCAT FAILS AFTER RECEIVING REQUEST */
 #define RECOVER_ABORT_IF_TCSENDHEADER    0x0002 /* DON'T RECOVER IF TOMCAT FAILS AFTER SENDING HEADERS */
@@ -316,6 +323,7 @@
     int ping_timeout;         /* generic cping/cpong timeout. Used for keepalive packets or
                                * as default for boolean valued connect and prepost timeouts.
                                */
+    unsigned int ping_mode;   /* Ping mode flags */
     /*
      * Recovery options
      */
@@ -419,6 +427,8 @@
 
 int JK_METHOD ajp_maintain(jk_worker_t *pThis, time_t now, jk_logger_t *l);
 
+int jk_ajp_get_cping_mode(const char *m, int def);
+
 #ifdef __cplusplus
 }
 #endif                          /* __cplusplus */

Modified: tomcat/connectors/trunk/jk/native/common/jk_util.c
URL: http://svn.apache.org/viewvc/tomcat/connectors/trunk/jk/native/common/jk_util.c?rev=697697&r1=697696&r2=697697&view=diff
==============================================================================
--- tomcat/connectors/trunk/jk/native/common/jk_util.c (original)
+++ tomcat/connectors/trunk/jk/native/common/jk_util.c Mon Sep 22 01:19:44 2008
@@ -58,6 +58,7 @@
 #define REPLY_TIMEOUT_OF_WORKER     ("reply_timeout")
 #define SOCKET_TIMEOUT_OF_WORKER    ("socket_timeout")
 #define PING_TIMEOUT_OF_WORKER      ("ping_timeout")
+#define PING_MODE_OF_WORKER         ("ping_mode")
 #define SOCKET_BUFFER_OF_WORKER     ("socket_buffer")
 #define SOCKET_KEEPALIVE_OF_WORKER  ("socket_keepalive")
 #define CONN_PING_INTERVAL_OF_WORKER  ("connection_ping_interval")
@@ -172,6 +173,7 @@
     CONNECT_TIMEOUT_OF_WORKER,
     PREPOST_TIMEOUT_OF_WORKER,
     PING_TIMEOUT_OF_WORKER,
+    PING_MODE_OF_WORKER,
     REPLY_TIMEOUT_OF_WORKER,
     SOCKET_TIMEOUT_OF_WORKER,
     SOCKET_BUFFER_OF_WORKER,
@@ -257,6 +259,7 @@
     CONNECT_TIMEOUT_OF_WORKER,
     PREPOST_TIMEOUT_OF_WORKER,
     PING_TIMEOUT_OF_WORKER,
+    PING_MODE_OF_WORKER,
     REPLY_TIMEOUT_OF_WORKER,
     SOCKET_TIMEOUT_OF_WORKER,
     SOCKET_BUFFER_OF_WORKER,
@@ -761,7 +764,7 @@
     if (!m || !wname) {
         return NULL;
     }
-   MAKE_WORKER_PARAM(REDIRECT_OF_WORKER);
+    MAKE_WORKER_PARAM(REDIRECT_OF_WORKER);
     return jk_map_get_string(m, buf, def);
 }
 
@@ -993,10 +996,8 @@
     }
 
     MAKE_WORKER_PARAM(CONNECT_TIMEOUT_OF_WORKER);
-    if ((rv = jk_map_get_bool(m, buf, -1)) == -1)
-        return jk_map_get_int(m, buf, AJP_DEF_CONNECT_TIMEOUT);
-    else
-        return def;
+
+    return jk_map_get_int(m, buf, def);
 }
 
 int jk_get_worker_prepost_timeout(jk_map_t *m, const char *wname, int def)
@@ -1010,10 +1011,7 @@
 
     MAKE_WORKER_PARAM(PREPOST_TIMEOUT_OF_WORKER);
 
-    if ((rv = jk_map_get_bool(m, buf, -1)) == -1)
-        return jk_map_get_int(m, buf, AJP_DEF_PREPOST_TIMEOUT);
-    else
-        return def;
+    return jk_map_get_int(m, buf, def);
 }
 
 int jk_get_worker_ping_timeout(jk_map_t *m, const char *wname, int def)
@@ -1029,6 +1027,21 @@
     return jk_map_get_int(m, buf, def);
 }
 
+int jk_get_worker_ping_mode(jk_map_t *m, const char *wname, int def)
+{
+    char buf[1024];
+    const char *v;
+
+    if (!m || !wname) {
+        return def;
+    }
+
+    MAKE_WORKER_PARAM(PING_MODE_OF_WORKER);
+
+    v = jk_map_get_string(m, buf, NULL);
+    return jk_ajp_get_cping_mode(v, def);
+}
+
 int jk_get_worker_reply_timeout(jk_map_t *m, const char *wname, int def)
 {
     char buf[1024];

Modified: tomcat/connectors/trunk/jk/native/common/jk_util.h
URL: http://svn.apache.org/viewvc/tomcat/connectors/trunk/jk/native/common/jk_util.h?rev=697697&r1=697696&r2=697697&view=diff
==============================================================================
--- tomcat/connectors/trunk/jk/native/common/jk_util.h (original)
+++ tomcat/connectors/trunk/jk/native/common/jk_util.h Mon Sep 22 01:19:44 2008
@@ -88,6 +88,8 @@
 
 int jk_get_worker_ping_timeout(jk_map_t *m, const char *wname, int def);
 
+int jk_get_worker_ping_mode(jk_map_t *m, const char *wname, int def);
+
 int jk_get_worker_recycle_timeout(jk_map_t *m, const char *wname, int def);
 
 int jk_get_worker_recover_timeout(jk_map_t *m, const char *wname, int def);

Modified: tomcat/connectors/trunk/jk/xdocs/miscellaneous/changelog.xml
URL: http://svn.apache.org/viewvc/tomcat/connectors/trunk/jk/xdocs/miscellaneous/changelog.xml?rev=697697&r1=697696&r2=697697&view=diff
==============================================================================
--- tomcat/connectors/trunk/jk/xdocs/miscellaneous/changelog.xml (original)
+++ tomcat/connectors/trunk/jk/xdocs/miscellaneous/changelog.xml Mon Sep 22 01:19:44 2008
@@ -49,7 +49,8 @@
         This allows filter chain to work properly. (mturk)
       </fix>
       <update>
-        Added connection_ping_interval and ping_timeout directives. (mturk)
+        Added connection_ping_interval, ping_timeout and ping_mode directives.
+        (mturk)
       </update>
       <fix>
         Apache: Use correct ld flags provided by apxs when building module.

Modified: tomcat/connectors/trunk/jk/xdocs/reference/workers.xml
URL: http://svn.apache.org/viewvc/tomcat/connectors/trunk/jk/xdocs/reference/workers.xml?rev=697697&r1=697696&r2=697697&view=diff
==============================================================================
--- tomcat/connectors/trunk/jk/xdocs/reference/workers.xml (original)
+++ tomcat/connectors/trunk/jk/xdocs/reference/workers.xml Mon Sep 22 01:19:44 2008
@@ -260,12 +260,43 @@
 </p>
 </directive>
 
-<directive name="connection_ping_timeout" default="0" required="false">
+<directive name="connection_ping_interval" default="0" required="false">
 Connections idle for longer than this interval in seconds are probed by
 CPING packets whether they still work. If set to zero (default),
 no such probes will be done.
-<p>To be able to use this feature <code>prepost_timeout</code> must be
-set to the desired timeout value.
+<p>To be able to use this feature <code>ping_timeout</code> must be
+set to the desired timeout value and <code>ping_mode</code> must include
+<code>I</code> flag.
+</p>
+<p>
+This feature has been added in <b>jk 1.2.27</b>.
+</p>
+</directive>
+
+<directive name="ping_timeout" default="10000" required="false">
+Connections idle for longer than this interval in miliseconds are probed by
+CPING packets whether they still work. The usage depend on the
+<code>ping_mode<code> flags used.
+<p>
+This feature has been added in <b>jk 1.2.27</b>.
+</p>
+</directive>
+
+<directive name="ping_mode" default="" required="false">
+Ping mode flags for active connections. The value can
+be combination of the following flags:
+<p><b>C</b> If set the connect ping mode will be used. If
+directive <code>connect_timeout</code> was not set, the
+value of <code>ping_timeout</code> will be used instead.
+</p>
+<p><b>P</b> If set the prepost ping mode will be used. If
+directive <code>prepost_timeout</code> was not set, the
+value of <code>ping_timeout</code> will be used instead.
+</p>
+<p><b>I</b> If set the interval ping mode will be used. If
+directive <code>connection_ping_interval</code> was not set, the
+value of <code>ping_timeout * 10</code> will be used as
+<code>connection_ping_interval</code> value.
 </p>
 <p>
 This feature has been added in <b>jk 1.2.27</b>.



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