tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rj...@apache.org
Subject svn commit: r611589 - in /tomcat/connectors/trunk/jk: native/common/jk_ajp13_worker.c native/common/jk_ajp14_worker.c native/common/jk_ajp_common.c native/common/jk_ajp_common.h xdocs/miscellaneous/changelog.xml
Date Sun, 13 Jan 2008 16:19:00 GMT
Author: rjung
Date: Sun Jan 13 08:18:59 2008
New Revision: 611589

URL: http://svn.apache.org/viewvc?rev=611589&view=rev
Log:
Refactor ajp13/ajp14 factories, move common parts into ajp_factory.

Modified:
    tomcat/connectors/trunk/jk/native/common/jk_ajp13_worker.c
    tomcat/connectors/trunk/jk/native/common/jk_ajp14_worker.c
    tomcat/connectors/trunk/jk/native/common/jk_ajp_common.c
    tomcat/connectors/trunk/jk/native/common/jk_ajp_common.h
    tomcat/connectors/trunk/jk/xdocs/miscellaneous/changelog.xml

Modified: tomcat/connectors/trunk/jk/native/common/jk_ajp13_worker.c
URL: http://svn.apache.org/viewvc/tomcat/connectors/trunk/jk/native/common/jk_ajp13_worker.c?rev=611589&r1=611588&r2=611589&view=diff
==============================================================================
--- tomcat/connectors/trunk/jk/native/common/jk_ajp13_worker.c (original)
+++ tomcat/connectors/trunk/jk/native/common/jk_ajp13_worker.c Sun Jan 13 08:18:59 2008
@@ -78,38 +78,17 @@
     ajp_worker_t *aw;
 
     JK_TRACE_ENTER(l);
-    if (name == NULL || w == NULL) {
-        JK_LOG_NULL_PARAMS(l);
-        JK_TRACE_EXIT(l);
+    if (ajp_worker_factory(w, name, l) == JK_FALSE)
         return 0;
-    }
 
-    aw = (ajp_worker_t *) calloc(1, sizeof(ajp_worker_t));
-    if (!aw) {
-        jk_log(l, JK_LOG_ERROR,
-               "malloc of private_data failed");
-        JK_TRACE_EXIT(l);
-        return 0;
-    }
-
-    aw->name = name;
+    aw = (*w)->worker_private;
     aw->proto = AJP13_PROTO;
-    aw->login = NULL;
-
-    aw->ep_cache_sz = 0;
-    aw->ep_cache = NULL;
-    aw->connect_retry_attempts = AJP_DEF_RETRY_ATTEMPTS;
-    aw->worker.worker_private = aw;
 
     aw->worker.validate = validate;
     aw->worker.init = init;
     aw->worker.get_endpoint = get_endpoint;
     aw->worker.destroy = destroy;
-    aw->worker.maintain = ajp_maintain;
-
-    aw->logon = NULL;           /* No Logon on AJP13 */
 
-    *w = &aw->worker;
     JK_TRACE_EXIT(l);
     return JK_AJP13_WORKER_TYPE;
 }

Modified: tomcat/connectors/trunk/jk/native/common/jk_ajp14_worker.c
URL: http://svn.apache.org/viewvc/tomcat/connectors/trunk/jk/native/common/jk_ajp14_worker.c?rev=611589&r1=611588&r2=611589&view=diff
==============================================================================
--- tomcat/connectors/trunk/jk/native/common/jk_ajp14_worker.c (original)
+++ tomcat/connectors/trunk/jk/native/common/jk_ajp14_worker.c Sun Jan 13 08:18:59 2008
@@ -371,31 +371,10 @@
     ajp_worker_t *aw;
 
     JK_TRACE_ENTER(l);
-
-    if (name == NULL || w == NULL) {
-        JK_LOG_NULL_PARAMS(l);
-        JK_TRACE_EXIT(l);
+    if (ajp_worker_factory(w, name, l) == JK_FALSE)
         return 0;
-    }
-
-    aw = (ajp_worker_t *) calloc(1, sizeof(ajp_worker_t));
-    if (!aw) {
-        jk_log(l, JK_LOG_ERROR,
-               "malloc of private data failed");
-       JK_TRACE_EXIT(l);
-       return 0;
-    }
-
-    aw->name = strdup(name);
-
-    if (!aw->name) {
-        free(aw);
-        jk_log(l, JK_LOG_ERROR,
-               "malloc failed for name");
-        JK_TRACE_EXIT(l);
-        return 0;
-    }
 
+    aw = (*w)->worker_private;
     aw->proto = AJP14_PROTO;
 
     aw->login = (jk_login_service_t *)malloc(sizeof(jk_login_service_t));
@@ -413,19 +392,12 @@
         (AJP14_CONTEXT_INFO_NEG | AJP14_PROTO_SUPPORT_AJP14_NEG);
     aw->login->web_server_name = NULL;  /* must be set in init */
 
-    aw->ep_cache_sz = 0;
-    aw->ep_cache = NULL;
-    aw->connect_retry_attempts = AJP_DEF_RETRY_ATTEMPTS;
-    aw->worker.worker_private = aw;
-
     aw->worker.validate = validate;
     aw->worker.init = init;
     aw->worker.get_endpoint = get_endpoint;
     aw->worker.destroy = destroy;
-    aw->worker.maintain = ajp_maintain;
 
     aw->logon = logon;          /* LogOn Handler for AJP14 */
-    *w = &aw->worker;
 
     JK_TRACE_EXIT(l);
     return JK_AJP14_WORKER_TYPE;

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=611589&r1=611588&r2=611589&view=diff
==============================================================================
--- tomcat/connectors/trunk/jk/native/common/jk_ajp_common.c (original)
+++ tomcat/connectors/trunk/jk/native/common/jk_ajp_common.c Sun Jan 13 08:18:59 2008
@@ -2471,6 +2471,48 @@
     return rc;
 }
 
+int JK_METHOD ajp_worker_factory(jk_worker_t **w,
+                                 const char *name, jk_logger_t *l)
+{
+    ajp_worker_t *aw;
+
+    JK_TRACE_ENTER(l);
+    if (name == NULL || w == NULL) {
+        JK_LOG_NULL_PARAMS(l);
+        JK_TRACE_EXIT(l);
+        return JK_FALSE;
+    }
+
+    aw = (ajp_worker_t *) calloc(1, sizeof(ajp_worker_t));
+    if (!aw) {
+        jk_log(l, JK_LOG_ERROR,
+               "malloc of private_data failed");
+        JK_TRACE_EXIT(l);
+        return JK_FALSE;
+    }
+
+    jk_open_pool(&aw->p,
+                 aw->buf,
+                 sizeof(jk_pool_atom_t) * TINY_POOL_SIZE);
+
+    strncpy(aw->name, name, JK_SHM_STR_SIZ);
+    aw->login = NULL;
+
+    aw->ep_cache_sz = 0;
+    aw->ep_cache = NULL;
+    aw->connect_retry_attempts = AJP_DEF_RETRY_ATTEMPTS;
+    aw->worker.worker_private = aw;
+
+    aw->worker.maintain = ajp_maintain;
+
+    aw->logon = NULL;
+
+    *w = &aw->worker;
+
+    JK_TRACE_EXIT(l);
+    return JK_TRUE;
+}
+
 int ajp_destroy(jk_worker_t **pThis, jk_logger_t *l, int proto)
 {
     JK_TRACE_ENTER(l);
@@ -2500,6 +2542,7 @@
             aw->login = NULL;
         }
 
+        jk_close_pool(&aw->p);
         free(aw);
         JK_TRACE_EXIT(l);
         return JK_TRUE;
@@ -2639,6 +2682,7 @@
             JK_TRACE_EXIT(l);
             return JK_TRUE;
         }
+
         JK_ENTER_CS(&aw->cs, rc);
         if (rc) {
             unsigned int n = 0, cnt = 0;

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=611589&r1=611588&r2=611589&view=diff
==============================================================================
--- tomcat/connectors/trunk/jk/native/common/jk_ajp_common.h (original)
+++ tomcat/connectors/trunk/jk/native/common/jk_ajp_common.h Sun Jan 13 08:18:59 2008
@@ -27,6 +27,7 @@
 
 #include "jk_service.h"
 #include "jk_msg_buff.h"
+#include "jk_shm.h"
 #include "jk_mt.h"
 
 #ifdef __cplusplus
@@ -232,9 +233,17 @@
 
 struct ajp_worker
 {
+    jk_worker_t worker;
+
+    char         name[JK_SHM_STR_SIZ+1];
+
+    jk_pool_t p;
+    jk_pool_atom_t buf[TINY_POOL_SIZE];
+
+    JK_CRIT_SEC cs;
+
     struct sockaddr_in worker_inet_addr;    /* Contains host and port */
     unsigned connect_retry_attempts;
-    const char *name;
     const char *host;
     int port;
     /*
@@ -244,7 +253,6 @@
      * 2. Cache size.
      * 3. An array of "open" endpoints.
      */
-    JK_CRIT_SEC cs;
     unsigned int ep_cache_sz;
     unsigned int ep_mincache_sz;
     unsigned int ep_maxcache_sz;
@@ -257,8 +265,6 @@
     /* Weak secret similar with ajp12, used in ajp13 */
     const char *secret;
 
-    jk_worker_t worker;
-
     /*
      * Post physical connect handler.
      * AJP14 will set here its login handler
@@ -355,6 +361,9 @@
 int ajp_init(jk_worker_t *pThis,
              jk_map_t *props,
              jk_worker_env_t *we, jk_logger_t *l, int proto);
+
+int JK_METHOD ajp_worker_factory(jk_worker_t **w,
+                                 const char *name, jk_logger_t *l);
 
 int ajp_destroy(jk_worker_t **pThis, jk_logger_t *l, int proto);
 

Modified: tomcat/connectors/trunk/jk/xdocs/miscellaneous/changelog.xml
URL: http://svn.apache.org/viewvc/tomcat/connectors/trunk/jk/xdocs/miscellaneous/changelog.xml?rev=611589&r1=611588&r2=611589&view=diff
==============================================================================
--- tomcat/connectors/trunk/jk/xdocs/miscellaneous/changelog.xml (original)
+++ tomcat/connectors/trunk/jk/xdocs/miscellaneous/changelog.xml Sun Jan 13 08:18:59 2008
@@ -44,6 +44,10 @@
   <subsection name="Native">
     <changelog>
       <update>
+        AJP: Refactor factories, move ajp13/ajp14 common parts into
+        ajp_factory. (rjung)
+      </update>
+      <update>
         Status: Only sync shm worker config values of the workers
         for which we changed values. (rjung)
       </update>



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


Mime
View raw message