tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mt...@apache.org
Subject svn commit: r439293 - in /tomcat/connectors/trunk/jk/native/common: jk_ajp_common.c jk_ajp_common.h jk_lb_worker.c jk_lb_worker.h jk_util.c jk_util.h
Date Fri, 01 Sep 2006 12:41:18 GMT
Author: mturk
Date: Fri Sep  1 05:41:17 2006
New Revision: 439293

URL: http://svn.apache.org/viewvc?rev=439293&view=rev
Log:
Make default AJP packet size configurable from
8K to 64K in 1K steps. It is up to the Tomcat to
decide if the packet is acceptable or not.
To be able to use this feature Tomcat AJP connector
will have to be modified. In other case the Tomcat
will return 400 indicating to the admin to change
the configuration according to the versions used.

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_lb_worker.h
    tomcat/connectors/trunk/jk/native/common/jk_util.c
    tomcat/connectors/trunk/jk/native/common/jk_util.h

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=439293&r1=439292&r2=439293&view=diff
==============================================================================
--- tomcat/connectors/trunk/jk/native/common/jk_ajp_common.c (original)
+++ tomcat/connectors/trunk/jk/native/common/jk_ajp_common.c Fri Sep  1 05:41:17 2006
@@ -1666,15 +1666,15 @@
 
     p = e->endpoint_private;
     op->request = jk_b_new(&(p->pool));
-    jk_b_set_buffer_size(op->request, DEF_BUFFER_SZ);
+    jk_b_set_buffer_size(op->request, p->worker->max_packet_size);
     jk_b_reset(op->request);
 
     op->reply = jk_b_new(&(p->pool));
-    jk_b_set_buffer_size(op->reply, DEF_BUFFER_SZ);
+    jk_b_set_buffer_size(op->reply, p->worker->max_packet_size);
     jk_b_reset(op->reply);
 
     op->post = jk_b_new(&(p->pool));
-    jk_b_set_buffer_size(op->post, DEF_BUFFER_SZ);
+    jk_b_set_buffer_size(op->post, p->worker->max_packet_size);
     jk_b_reset(op->post);
 
     op->recoverable = JK_TRUE;
@@ -1955,6 +1955,8 @@
         p->recovery_opts =
             jk_get_worker_recovery_opts(props, p->name,
                                         AJP_DEF_RECOVERY_OPTS);
+        p->max_packet_size =
+            jk_get_max_packet_size(props, p->name);
 
         pThis->retries =
             jk_get_worker_retries(props, p->name,
@@ -2006,6 +2008,10 @@
             jk_log(l, JK_LOG_DEBUG,
                    "retries:          %d",
                     pThis->retries);
+
+            jk_log(l, JK_LOG_DEBUG,
+                   "max packet size:  %d",
+                    p->max_packet_size);
         }
         /*
          *  Need to initialize secret here since we could return from inside

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=439293&r1=439292&r2=439293&view=diff
==============================================================================
--- tomcat/connectors/trunk/jk/native/common/jk_ajp_common.h (original)
+++ tomcat/connectors/trunk/jk/native/common/jk_ajp_common.h Fri Sep  1 05:41:17 2006
@@ -283,7 +283,9 @@
     /*
      * Recovery option
      */
-    unsigned recovery_opts; /* Set the recovery option */
+    unsigned int recovery_opts; /* Set the recovery option */
+    
+    unsigned int max_packet_size;  /*  Maximum AJP Packet size */
 };
 
 

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=439293&r1=439292&r2=439293&view=diff
==============================================================================
--- tomcat/connectors/trunk/jk/native/common/jk_lb_worker.c (original)
+++ tomcat/connectors/trunk/jk/native/common/jk_lb_worker.c Fri Sep  1 05:41:17 2006
@@ -621,7 +621,7 @@
 
     /* set the recovery post, for LB mode */
     s->reco_buf = jk_b_new(s->pool);
-    jk_b_set_buffer_size(s->reco_buf, DEF_BUFFER_SZ);
+    jk_b_set_buffer_size(s->reco_buf, p->worker->max_packet_size);
     jk_b_reset(s->reco_buf);
     s->reco_status = RECO_INITED;
     if (p->worker->s->sticky_session) {
@@ -957,7 +957,7 @@
                                   &num_of_workers) && num_of_workers) {
             unsigned int i = 0;
             unsigned int j = 0;
-
+            p->max_packet_size = DEF_BUFFER_SZ;
             p->lb_workers = jk_pool_alloc(&p->p,
                                           num_of_workers *
                                           sizeof(worker_record_t));
@@ -975,6 +975,15 @@
                     return JK_FALSE;
                 }
             }
+
+            /* Calculate the maximum packet size from all workers
+             * for the recovery buffer.
+             */
+            for (i = 0; i < num_of_workers; i++) {
+                unsigned int ms = jk_get_max_packet_size(props, worker_names[i]);
+                if (ms > p->max_packet_size)
+                    p->max_packet_size = ms;
+           }
             for (i = 0; i < num_of_workers; i++) {
                 const char *s;
                 strncpy(p->lb_workers[i].s->name, worker_names[i],

Modified: tomcat/connectors/trunk/jk/native/common/jk_lb_worker.h
URL: http://svn.apache.org/viewvc/tomcat/connectors/trunk/jk/native/common/jk_lb_worker.h?rev=439293&r1=439292&r2=439293&view=diff
==============================================================================
--- tomcat/connectors/trunk/jk/native/common/jk_lb_worker.h (original)
+++ tomcat/connectors/trunk/jk/native/common/jk_lb_worker.h Fri Sep  1 05:41:17 2006
@@ -153,6 +153,7 @@
     int          lbmethod;
     int          lblock;
     time_t       maintain_time;
+    unsigned int max_packet_size;
 
     jk_pool_t p;
     jk_pool_atom_t buf[TINY_POOL_SIZE];

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=439293&r1=439292&r2=439293&view=diff
==============================================================================
--- tomcat/connectors/trunk/jk/native/common/jk_util.c (original)
+++ tomcat/connectors/trunk/jk/native/common/jk_util.c Fri Sep  1 05:41:17 2006
@@ -76,6 +76,7 @@
 #define IS_WORKER_STOPPED           ("stopped")
 #define ACTIVATION_OF_WORKER        ("activation")
 #define WORKER_RECOVER_TIME         ("recover_time")
+#define WORKER_MAX_PACKET_SIZE      ("max_packet_size")
 
 
 #define DEFAULT_WORKER_TYPE         JK_AJP13_WORKER_NAME
@@ -891,6 +892,26 @@
         return JK_LB_LOCK_PESSIMISTIC;
     else
         return JK_LB_LOCK_DEF;
+}
+
+int jk_get_max_packet_size(jk_map_t *m, const char *wname)
+{
+    char buf[1024];
+    int sz;
+
+    if (!m || !wname) {
+        return DEF_BUFFER_SZ;
+    }
+
+    MAKE_WORKER_PARAM(DISTANCE_OF_WORKER);
+    sz = jk_map_get_int(m, buf, DEF_BUFFER_SZ);
+    sz = JK_ALIGN(sz, 1024);
+    if (sz < DEF_BUFFER_SZ)
+        sz = DEF_BUFFER_SZ;
+    else if (sz > 64*1024)
+        sz = 64*1024;
+    
+    return sz;
 }
 
 int jk_get_lb_worker_list(jk_map_t *m,

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=439293&r1=439292&r2=439293&view=diff
==============================================================================
--- tomcat/connectors/trunk/jk/native/common/jk_util.h (original)
+++ tomcat/connectors/trunk/jk/native/common/jk_util.h Fri Sep  1 05:41:17 2006
@@ -166,6 +166,8 @@
 
 int jk_get_worker_maintain_time(jk_map_t *m);
 
+int jk_get_max_packet_size(jk_map_t *m, const char *wname);
+
 #define TC32_BRIDGE_TYPE    32
 #define TC33_BRIDGE_TYPE    33
 #define TC40_BRIDGE_TYPE    40



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


Mime
View raw message