costin 01/12/06 14:48:50
Modified: jk/native2/include jk_channel.h jk_endpoint.h jk_env.h
jk_handler.h jk_logger.h jk_map.h jk_pool.h
jk_service.h jk_uriEnv.h jk_uriMap.h jk_worker.h
jk_workerEnv.h
Log:
- Added pools wherever they're needed.
Factory now takes a pool - that allows us to get rid of 1/2 of mallocs and
be sure the data will be cleaned.
- Pass pool to methods that could be called at run time and may need
to create temp data ( we don't want to allocate temp data in the object's pool,
but in the caller pool or a temp pool - which is short-lived )
- Get rid of all buf[]s. Now all pools are created using the pool hierarchy -
i.e. from apr_pools or malloc. Since we recycle, there's no need to play all
the stack-allocation tricks.
- moved the jk_pool-specific private data to the impl. The common implementation
will be used only if APR ( or other server-specific native pools ) are not available.
- removed the per/context fileds from the per/uri structure
Revision Changes Path
1.2 +1 -4 jakarta-tomcat-connectors/jk/native2/include/jk_channel.h
Index: jk_channel.h
===================================================================
RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native2/include/jk_channel.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- jk_channel.h 2001/12/01 22:30:57 1.1
+++ jk_channel.h 2001/12/06 22:48:49 1.2
@@ -105,11 +105,8 @@
*/
char **supportedProperties;
- struct jk_worker *worker; /* XXX Do we need it ? */
- jk_logger_t *logger;
+ struct jk_worker *worker;
jk_map_t *properties;
- jk_pool_t *pool; /* XXX Do we need it ? */
-
/** Prepare the channel, check the properties. This
* will resolve the host and do all the validations.
1.3 +4 -3 jakarta-tomcat-connectors/jk/native2/include/jk_endpoint.h
Index: jk_endpoint.h
===================================================================
RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native2/include/jk_endpoint.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- jk_endpoint.h 2001/12/05 20:45:13 1.2
+++ jk_endpoint.h 2001/12/06 22:48:49 1.3
@@ -61,7 +61,7 @@
* Author: Gal Shachor <[EMAIL PROTECTED]>
* Author: Dan Milstein <[EMAIL PROTECTED]>
* Author: Henri Gomez <[EMAIL PROTECTED]>
- * Version: $Revision: 1.2 $
+ * Version: $Revision: 1.3 $
***************************************************************************/
#ifndef JK_ENDPOINT_H
@@ -127,8 +127,9 @@
struct jk_worker *worker;
- jk_pool_t pool;
- jk_pool_atom_t buf[BIG_POOL_SIZE];
+ /** Each thread has it's own endpoint instance and is recycled.
+ This pool can be unsynchronized */
+ jk_pool_t *pool;
int proto; /* PROTOCOL USED AJP13/AJP14 */
1.2 +5 -3 jakarta-tomcat-connectors/jk/native2/include/jk_env.h
Index: jk_env.h
===================================================================
RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native2/include/jk_env.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- jk_env.h 2001/12/01 22:30:57 1.1
+++ jk_env.h 2001/12/06 22:48:49 1.2
@@ -80,6 +80,7 @@
* @author Costin Manolache
*
*/
+struct jk_pool;
struct jk_env;
typedef struct jk_env jk_env_t;
@@ -101,6 +102,7 @@
* jk_worker_list.h).
*/
typedef int (JK_METHOD *jk_env_objectFactory_t)(jk_env_t *env,
+ jk_pool_t *pool,
void **result,
const char *type,
const char *name);
@@ -108,7 +110,7 @@
/** Get a pointer to the jk_env. We could support multiple
* env 'instances' in future - for now it's a singleton.
*/
-jk_env_t* JK_METHOD jk_env_getEnv( char *id );
+jk_env_t* JK_METHOD jk_env_getEnv( char *id, struct jk_pool *pool );
/**
@@ -120,7 +122,7 @@
*/
struct jk_env {
jk_logger_t *logger;
- /*jk_pool_t global_pool; */
+ jk_pool_t *globalPool;
/** Global properties ( similar with System properties in java)
*/
@@ -136,7 +138,7 @@
call it. This is a very frequent operation.
*/
void *
- (JK_METHOD *getInstance)( jk_env_t *env, const char *type,
+ (JK_METHOD *getInstance)( jk_env_t *env, jk_pool_t *pool, const char *type,
const char *name );
1.2 +1 -0 jakarta-tomcat-connectors/jk/native2/include/jk_handler.h
Index: jk_handler.h
===================================================================
RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native2/include/jk_handler.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- jk_handler.h 2001/12/05 20:45:13 1.1
+++ jk_handler.h 2001/12/06 22:48:49 1.2
@@ -97,6 +97,7 @@
typedef struct jk_handler jk_handler_t;
struct jk_handler {
+ struct jk_workerEnv *workerEnv;
int (*init)( jk_worker_t *w );
1.3 +4 -2 jakarta-tomcat-connectors/jk/native2/include/jk_logger.h
Index: jk_logger.h
===================================================================
RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native2/include/jk_logger.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- jk_logger.h 2001/12/02 02:09:45 1.2
+++ jk_logger.h 2001/12/06 22:48:49 1.3
@@ -58,7 +58,7 @@
/***************************************************************************
* Description: Logger object definitions *
* Author: Gal Shachor <[EMAIL PROTECTED]> *
- * Version: $Revision: 1.2 $ *
+ * Version: $Revision: 1.3 $ *
***************************************************************************/
#ifndef JK_LOGGER_H
@@ -71,6 +71,8 @@
extern "C" {
#endif /* __cplusplus */
+struct jk_map;
+struct jk_logger;
typedef struct jk_logger jk_logger_t;
/* Logger object.
@@ -91,7 +93,7 @@
const char *def );
int (JK_METHOD *open)( jk_logger_t *_this,
- jk_map_t *properties );
+ struct jk_map *properties );
void (JK_METHOD *close)( jk_logger_t *_this );
1.3 +15 -4 jakarta-tomcat-connectors/jk/native2/include/jk_map.h
Index: jk_map.h
===================================================================
RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native2/include/jk_map.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- jk_map.h 2001/12/05 20:45:13 1.2
+++ jk_map.h 2001/12/06 22:48:49 1.3
@@ -58,22 +58,25 @@
/***************************************************************************
* Description: Map object header file *
* Author: Gal Shachor <[EMAIL PROTECTED]> *
- * Version: $Revision: 1.2 $ *
+ * Version: $Revision: 1.3 $ *
***************************************************************************/
#ifndef JK_MAP_H
#define JK_MAP_H
+#include "jk_pool.h"
+#include "jk_logger.h"
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
-
+struct jk_logger;
+struct jk_pool;
struct jk_map;
typedef struct jk_map jk_map_t;
-int map_alloc(jk_map_t **m);
+int map_alloc(jk_map_t **m, struct jk_pool *pool);
int map_free(jk_map_t **m);
@@ -97,7 +100,13 @@
const char *name,
const char *def);
+/** Extract a String[] property. It'll split the value on
+ * ' ', tab, ',', '*'.
+ * @param pool Pool on which the result will be allocated. Defaults to the map's
+ * pool
+ */
char **map_get_string_list(jk_map_t *m,
+ struct jk_pool *pool,
const char *name,
unsigned *list_len,
const char *def);
@@ -152,9 +161,11 @@
const char *pname,
unsigned *size);
+int map_copy(jk_pool_t *pool, jk_map_t * src, jk_map_t * dst);
+
/* XXX Very strange hack to deal with special properties
*/
- int jk_is_some_property(const char *prp_name, const char *suffix);
+int jk_is_some_property(const char *prp_name, const char *suffix);
#ifdef __cplusplus
}
1.4 +18 -28 jakarta-tomcat-connectors/jk/native2/include/jk_pool.h
Index: jk_pool.h
===================================================================
RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native2/include/jk_pool.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- jk_pool.h 2001/12/05 20:45:13 1.3
+++ jk_pool.h 2001/12/06 22:48:49 1.4
@@ -58,7 +58,7 @@
/***************************************************************************
* Description: Memory Pool object header file *
* Author: Gal Shachor <[EMAIL PROTECTED]> *
- * Version: $Revision: 1.3 $ *
+ * Version: $Revision: 1.4 $ *
***************************************************************************/
#ifndef _JK_POOL_H
#define _JK_POOL_H
@@ -120,18 +120,24 @@
typedef struct jk_pool jk_pool_t;
-/** XXX Move it to impl, make it incomplete
- */
+/** The pool can grow by (m)allocating more storage, but it'll first use buf.
+*/
struct jk_pool {
-
- void (*open)(jk_pool_t *_this,
- jk_pool_atom_t *buf,
- unsigned size);
+ /** Create a child pool. Size is a hint for the
+ * estimated needs of the child.
+ */
+ jk_pool_t *(*create)(jk_pool_t *_this,
+ int size );
void (*close)(jk_pool_t *_this);
-
+
+ /** Empty the pool using the same space.
+ * XXX should we rename it to clear() - consistent with apr ?
+ */
void (*reset)(jk_pool_t *_this);
+ /* Memory allocation */
+
void *(*alloc)(jk_pool_t *_this, size_t size);
void *(*realloc)(jk_pool_t *_this, size_t size,
@@ -144,31 +150,15 @@
/** Points to the private data. In the case of APR,
it's a apr_pool you can use directly */
void *_private;
-
- /* Private data - XXX move to impl */
- unsigned size;
- unsigned pos;
- jk_pool_atom_t *buf;
- int own_buffer;
- unsigned dyn_size;
- unsigned dyn_pos;
- void **dynamic;
};
+
+/** Create a pool. Use it for the initial allocation ( in mod_jk ). All other
+ pools should be created using the virtual method.
-/** Create a pool
+ XXX move this to the factory
*/
int jk_pool_create( jk_pool_t **newPool, jk_pool_t *parent, int size );
-/** Open a pool using allocated space. The pool can grow by
- (m)allocating more storage, but it'll first use buf.
- This is used in jk with stack-allocated pools.
-*/
-void jk_pool_open(jk_pool_t *p, jk_pool_atom_t *buf, unsigned size);
-
-
-void jk_open_pool(jk_pool_t *p,
- jk_pool_atom_t *buf,
- unsigned size);
#ifdef __cplusplus
}
1.3 +3 -2 jakarta-tomcat-connectors/jk/native2/include/jk_service.h
Index: jk_service.h
===================================================================
RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native2/include/jk_service.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- jk_service.h 2001/12/04 18:33:05 1.2
+++ jk_service.h 2001/12/06 22:48:49 1.3
@@ -63,7 +63,7 @@
* Author: Gal Shachor <[EMAIL PROTECTED]> *
* Author: Dan Milstein <[EMAIL PROTECTED]> *
* Author: Henri Gomez <[EMAIL PROTECTED]> *
- * Version: $Revision: 1.2 $ *
+ * Version: $Revision: 1.3 $ *
***************************************************************************/
#ifndef JK_SERVICE_H
@@ -135,7 +135,8 @@
* allocated within this pool, which can then be reclaimed at the end
* of the request handling cycle.
*
- * Alive as long as the request is alive.
+ * Alive as long as the request is alive.
+ * You can use endpoint pool for communication - it is recycled.
*/
jk_pool_t *pool;
1.4 +17 -55 jakarta-tomcat-connectors/jk/native2/include/jk_uriEnv.h
Index: jk_uriEnv.h
===================================================================
RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native2/include/jk_uriEnv.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- jk_uriEnv.h 2001/12/05 20:45:13 1.3
+++ jk_uriEnv.h 2001/12/06 22:48:49 1.4
@@ -82,7 +82,12 @@
struct jk_env;
struct jk_uri_worker_map;
struct jk_map;
+struct jk_webapp;
+struct jk_uriEnv;
+typedef struct jk_uriEnv jk_uriEnv_t;
+
+
#define MATCH_TYPE_EXACT (0)
#define MATCH_TYPE_CONTEXT (1)
#define MATCH_TYPE_SUFFIX (2)
@@ -92,35 +97,18 @@
struct jk_uriEnv {
struct jk_workerEnv *workerEnv;
+ struct jk_webapp *webapp;
+
/* Generic name/value properties. Some workers may use it.
*/
struct jk_map *properties;
-
- /** Worker associated with this location.
- Inherited by virtual host, context ( i.e. you can override
- it if you want, the default will be the 'global' default worker,
- or the virtual host worker ).
- */
- struct jk_worker *worker;
- /** worker name - allow this to be set before the worker is defined.
- * XXX do we need it ?
- */
- char *workerName;
-
- /* Virtual server handled - "*" is all virtual.
- */
- char *virtual;
- char *uri;
-
- /** Web application. No need to compute it again in tomcat.
- * The 'id' is the index in the context table ( todo ), it
- * reduce the ammount of trafic ( and string creation on java )
+ /* Original uri ( unparsed )
*/
- char *context;
- int contextId;
+ char *uri;
- char *docbase;
+ /** XXX todo.
+ */
int status;
/** Servlet. No need to compute it again in tomcat
@@ -128,46 +116,20 @@
char *servlet;
int servletId;
- /* ---------- For our internal mapper use ---------- */
+ /* Extracted suffix, for extension-based mathces */
char *suffix;
- int ctxt_len;
- int match_type;
-
- /** You can fine-tune the logging level per location
- */
- int log_level;
-
- /** Different apps can have different loggers.
- */
- jk_logger_t *l;
-
- /* SSL Support - you can fine tune this per application.
- * ( most likely you only do it per virtual host or globally )
- * XXX shouldn't SSL be enabled by default ???
- */
- int ssl_enable;
- char *https_indicator;
- char *certs_indicator;
- char *cipher_indicator;
- char *session_indicator;
- char *key_size_indicator;
-
- /* Jk Options. Bitflag.
- */
- int options;
+ char *prefix;
+
+ int prefix_len;
+ int suffix_len;
- /* Environment variables support
- */
- int envvars_in_use;
- jk_map_t * envvars;
+ int match_type;
/* -------------------- Methods -------------------- */
/* get/setProperty */
};
-
-typedef struct jk_uriEnv jk_uriEnv_t;
#ifdef __cplusplus
1.5 +4 -7 jakarta-tomcat-connectors/jk/native2/include/jk_uriMap.h
Index: jk_uriMap.h
===================================================================
RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native2/include/jk_uriMap.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- jk_uriMap.h 2001/12/05 20:45:13 1.4
+++ jk_uriMap.h 2001/12/06 22:48:49 1.5
@@ -138,13 +138,10 @@
/* -------------------- @deprecated -------------------- */
/* used by the mapper, temp storage ( ??? )*/
- /* Memory Pool */
- jk_pool_t p;
- jk_pool_atom_t buf[SMALL_POOL_SIZE];
-
- /* Temp Pool */
- jk_pool_t tp;
- jk_pool_atom_t tbuf[SMALL_POOL_SIZE];
+ /* pool for mappings. Mappings will change at runtime, we can't
+ * recycle the main pool.
+ */
+ jk_pool_t *pool;
};
#ifdef __cplusplus
1.4 +5 -1 jakarta-tomcat-connectors/jk/native2/include/jk_worker.h
Index: jk_worker.h
===================================================================
RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native2/include/jk_worker.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- jk_worker.h 2001/12/05 20:45:13 1.3
+++ jk_worker.h 2001/12/06 22:48:49 1.4
@@ -58,7 +58,7 @@
/***************************************************************************
* Description: Workers controller header file *
* Author: Gal Shachor <[EMAIL PROTECTED]> *
- * Version: $Revision: 1.3 $ *
+ * Version: $Revision: 1.4 $ *
***************************************************************************/
#ifndef JK_WORKER_H
@@ -170,6 +170,10 @@
struct jk_workerEnv *workerEnv;
char *name;
+ /** Pool for worker specific informations.
+ In future we may start/stop/reload workers at runtime, but that's
+ far away
+ */
jk_pool_t *pool;
/*
1.4 +14 -1 jakarta-tomcat-connectors/jk/native2/include/jk_workerEnv.h
Index: jk_workerEnv.h
===================================================================
RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native2/include/jk_workerEnv.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- jk_workerEnv.h 2001/12/05 20:45:13 1.3
+++ jk_workerEnv.h 2001/12/06 22:48:49 1.4
@@ -58,7 +58,7 @@
/***************************************************************************
* Description: Workers controller header file *
* Author: Gal Shachor <[EMAIL PROTECTED]> *
- * Version: $Revision: 1.3 $ *
+ * Version: $Revision: 1.4 $ *
***************************************************************************/
#ifndef JK_WORKERENV_H
@@ -69,6 +69,7 @@
#include "jk_worker.h"
#include "jk_map.h"
#include "jk_uriMap.h"
+#include "jk_webapp.h"
#ifdef __cplusplus
extern "C" {
@@ -78,6 +79,7 @@
struct jk_endpoint;
struct jk_env;
struct jk_uriMap;
+struct jk_webapp;
struct jk_map;
/*
@@ -95,6 +97,10 @@
*/
/* struct jk_map *uri_to_context; */
+ /* Use this pool for all global settings
+ */
+ struct jk_pool *pool;
+
/* Workers hashtable. You can also access workers by id
*/
struct jk_map *worker_map;
@@ -146,6 +152,9 @@
struct jk_uriMap *uriMap;
+ struct jk_webapp *rootWebapp;
+ struct jk_map *webapps;
+
/** If 'global' server mappings will be visible in virtual hosts
as well. XXX Not sure this is needed
*/
@@ -195,6 +204,10 @@
const char *name,
struct jk_map *init_data);
+ struct jk_webapp *(*createWebapp)(struct jk_workerEnv *_this,
+ const char *vhost,
+ const char *name,
+ struct jk_map *init_data);
/**
* Init the workers, prepare the worker environment.
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>