costin 01/12/05 12:45:13 Modified: jk/native2/include jk_endpoint.h jk_map.h jk_pool.h jk_uriEnv.h jk_uriMap.h jk_worker.h jk_workerEnv.h Added: jk/native2/include jk_handler.h Log: Changed 'unsigned' to normal 'int's - unsingneds are a bit confusing ( for a java programmer :-), and the code already had few 'foo>0' or even 'foo=-1' with foo unsigned. Please avoid unsigned if possible, for most of our stuff int should be enough. Continued the data structure consolidation. As I mentioned in a previous commit, we lose some of the data hiding (the 'private' fields ), but we gain the ability to extract detailed informations about what's going in and to control all data structures using callbacks from tomcat. Long term we need some 'introspection' capabilities, most likely a generic getProperty/setProperty ( or getNote/setNote - 3.3 style ) plus getPropertyNames(). Now load balancing properties are visible in the main worker. Of course, most of it is quite generic - for example 'realEndpoint' is to be used by any worker that is using another worker to do the work. Having lb exposed will eventually allow us to finish jni worker in multiprocess mode. Added prototypes, get rid of most warnings. Revision Changes Path 1.2 +25 -2 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.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- jk_endpoint.h 2001/12/04 18:29:11 1.1 +++ jk_endpoint.h 2001/12/05 20:45:13 1.2 @@ -1,4 +1,3 @@ -/* -*- Mode: C; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil-*- */ /* ========================================================================= * * * * The Apache Software License, Version 1.1 * @@ -62,7 +61,7 @@ * Author: Gal Shachor <[EMAIL PROTECTED]> * Author: Dan Milstein <[EMAIL PROTECTED]> * Author: Henri Gomez <[EMAIL PROTECTED]> - * Version: $Revision: 1.1 $ + * Version: $Revision: 1.2 $ ***************************************************************************/ #ifndef JK_ENDPOINT_H @@ -135,7 +134,7 @@ int sd; int reuse; - unsigned left_bytes_to_send; + int left_bytes_to_send; /* Buffers for req/res */ /* Used to be ajp_operation */ @@ -145,7 +144,13 @@ int uploadfd; /* future persistant storage id */ int recoverable; /* if exchange could be conducted on another TC */ + /* For redirecting endpoints like lb */ + jk_endpoint_t *realEndpoint; + /* int (JK_METHOD *sendRequest)(jk_endpoint_t *e, */ + /* struct jk_ws_service *s, */ + /* jk_logger_t *l ); */ + /* * Forward a request to the servlet engine. The request is described * by the jk_ws_service_t object. I'm not sure exactly how @@ -188,6 +193,24 @@ int ajp_connection_tcp_get_message(jk_endpoint_t *ae, jk_msg_buf_t *msg, jk_logger_t *l); + + +int ajp_send_request(jk_endpoint_t *e, + struct jk_ws_service *s, + jk_logger_t *l); + +int ajp_get_reply(jk_endpoint_t *e, + struct jk_ws_service *s, + jk_logger_t *l); + +void ajp_reset_endpoint(jk_endpoint_t *ae); + +int ajp_read_into_msg_buff(jk_endpoint_t *ae, + struct jk_ws_service *r, + jk_msg_buf_t *msg, + int len, + jk_logger_t *l); + #ifdef __cplusplus 1.2 +17 -2 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.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- jk_map.h 2001/12/01 22:30:57 1.1 +++ jk_map.h 2001/12/05 20:45:13 1.2 @@ -58,7 +58,7 @@ /*************************************************************************** * Description: Map object header file * * Author: Gal Shachor <[EMAIL PROTECTED]> * - * Version: $Revision: 1.1 $ * + * Version: $Revision: 1.2 $ * ***************************************************************************/ #ifndef JK_MAP_H @@ -132,7 +132,7 @@ const char *objType, const char *objName, const char *pname, - const char *def); + char *def); int map_getIntProp(jk_map_t *m, const char *objType, @@ -140,6 +140,21 @@ const char *pname, const int def); +double map_getDoubleProp(jk_map_t *m, + const char *objType, + const char *objName, + const char *pname, + const double def); + +char **map_getListProp(jk_map_t *m, + const char *objType, + const char *objName, + const char *pname, + unsigned *size); + +/* XXX Very strange hack to deal with special properties + */ + int jk_is_some_property(const char *prp_name, const char *suffix); #ifdef __cplusplus } 1.3 +4 -3 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.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- jk_pool.h 2001/12/04 23:56:06 1.2 +++ jk_pool.h 2001/12/05 20:45:13 1.3 @@ -58,7 +58,7 @@ /*************************************************************************** * Description: Memory Pool object header file * * Author: Gal Shachor <[EMAIL PROTECTED]> * - * Version: $Revision: 1.2 $ * + * Version: $Revision: 1.3 $ * ***************************************************************************/ #ifndef _JK_POOL_H #define _JK_POOL_H @@ -148,7 +148,8 @@ /* Private data - XXX move to impl */ unsigned size; unsigned pos; - char *buf; + jk_pool_atom_t *buf; + int own_buffer; unsigned dyn_size; unsigned dyn_pos; void **dynamic; @@ -156,7 +157,7 @@ /** Create a pool */ -int jk_pool_create( jk_pool_t **newPool, jk_pool_t *parent ); +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. 1.3 +1 -1 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.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- jk_uriEnv.h 2001/12/04 18:33:05 1.2 +++ jk_uriEnv.h 2001/12/05 20:45:13 1.3 @@ -130,7 +130,7 @@ /* ---------- For our internal mapper use ---------- */ char *suffix; - unsigned int ctxt_len; + int ctxt_len; int match_type; /** You can fine-tune the logging level per location 1.4 +3 -3 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.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- jk_uriMap.h 2001/12/04 23:56:06 1.3 +++ jk_uriMap.h 2001/12/05 20:45:13 1.4 @@ -93,8 +93,8 @@ struct jk_uriMap { /* map URI->WORKER */ struct jk_uriEnv **maps; - unsigned int size; - unsigned int capacity; + int size; + int capacity; struct jk_workerEnv *workerEnv; int debug; @@ -119,7 +119,7 @@ /** Check the uri for potential security problems */ int (*checkUri)( jk_uriMap_t *_this, - char *uri ); + const char *uri ); /** Mapping the uri. To be thread safe, we need to pass a pool. Or even better, create the jk_service structure already. 1.3 +21 -4 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.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- jk_worker.h 2001/12/04 18:33:05 1.2 +++ jk_worker.h 2001/12/05 20:45:13 1.3 @@ -58,7 +58,7 @@ /*************************************************************************** * Description: Workers controller header file * * Author: Gal Shachor <[EMAIL PROTECTED]> * - * Version: $Revision: 1.2 $ * + * Version: $Revision: 1.3 $ * ***************************************************************************/ #ifndef JK_WORKER_H @@ -169,6 +169,8 @@ struct jk_workerEnv *workerEnv; char *name; + + jk_pool_t *pool; /* * A 'this' pointer which is used by the subclasses of this class to @@ -187,7 +189,7 @@ /* XXX Stuff from ajp, some is generic, some not - need to sort out after */ struct sockaddr_in worker_inet_addr; /* Contains host and port */ - unsigned connect_retry_attempts; + int connect_retry_attempts; /* * Open connections cache... @@ -197,12 +199,27 @@ * 3. An array of "open" endpoints. */ JK_CRIT_SEC cs; - unsigned ep_cache_sz; + int ep_cache_sz; struct jk_endpoint **ep_cache; int proto; struct jk_login_service *login; - + + /* Each worker can be part of a load-balancer scheme. + * The information can be accessed by other components - + * for example to report status, etc. + */ + double lb_factor; + double lb_value; + int in_error_state; + int in_recovering; + time_t error_time; + + /** If num_of_workers > 0 this is an load balancing worker + */ + jk_worker_t **lb_workers; + int num_of_workers; + int (* logon)(struct jk_endpoint *ae, jk_logger_t *l); 1.3 +2 -2 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.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- jk_workerEnv.h 2001/12/02 01:04:51 1.2 +++ jk_workerEnv.h 2001/12/05 20:45:13 1.3 @@ -58,7 +58,7 @@ /*************************************************************************** * Description: Workers controller header file * * Author: Gal Shachor <[EMAIL PROTECTED]> * - * Version: $Revision: 1.2 $ * + * Version: $Revision: 1.3 $ * ***************************************************************************/ #ifndef JK_WORKERENV_H @@ -109,7 +109,7 @@ to avoid the lookup */ struct jk_worker *defaultWorker; - + /* Web-Server we're running on (Apache/IIS/NES). */ char *server_name; 1.1 jakarta-tomcat-connectors/jk/native2/include/jk_handler.h Index: jk_handler.h =================================================================== /* -*- Mode: C; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil-*- */ /* ========================================================================= * * * * The Apache Software License, Version 1.1 * * * * Copyright (c) 1999-2001 The Apache Software Foundation. * * All rights reserved. * * * * ========================================================================= * * * * Redistribution and use in source and binary forms, with or without modi- * * fication, are permitted provided that the following conditions are met: * * * * 1. Redistributions of source code must retain the above copyright notice * * notice, this list of conditions and the following disclaimer. * * * * 2. Redistributions in binary form must reproduce the above copyright * * notice, this list of conditions and the following disclaimer in the * * documentation and/or other materials provided with the distribution. * * * * 3. The end-user documentation included with the redistribution, if any, * * must include the following acknowlegement: * * * * "This product includes software developed by the Apache Software * * Foundation <http://www.apache.org/>." * * * * Alternately, this acknowlegement may appear in the software itself, if * * and wherever such third-party acknowlegements normally appear. * * * * 4. The names "The Jakarta Project", "Jk", and "Apache Software * * Foundation" must not be used to endorse or promote products derived * * from this software without prior written permission. For written * * permission, please contact <[EMAIL PROTECTED]>. * * * * 5. Products derived from this software may not be called "Apache" nor may * * "Apache" appear in their names without prior written permission of the * * Apache Software Foundation. * * * * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES * * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY * * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL * * THE APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY * * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, * * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN * * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * * POSSIBILITY OF SUCH DAMAGE. * * * * ========================================================================= * * * * This software consists of voluntary contributions made by many indivi- * * duals on behalf of the Apache Software Foundation. For more information * * on the Apache Software Foundation, please see <http://www.apache.org/>. * * * * ========================================================================= */ /** * Handle jk messages. Each handler will register a number of * callbacks for certain message types. * * This is based on a simple generalization of the code in ajp13, * with the goal of making the system extensible for ajp14. * * @author Costin Manolache */ #ifndef JK_HANDLER_H #define JK_HANDLER_H #include "jk_global.h" #include "jk_map.h" #include "jk_workerEnv.h" #include "jk_logger.h" #include "jk_pool.h" #include "jk_uriMap.h" #include "jk_worker.h" #include "jk_endpoint.h" #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ typedef int (JK_METHOD *jk_handle_in_t)(jk_msg_buf_t *msg, jk_ws_service_t *r, jk_endpoint_t *ae, jk_logger_t *l); typedef int (JK_METHOD *jk_handle_out_t)(jk_msg_buf_t *msg, jk_ws_service_t *r, jk_endpoint_t *ae, jk_logger_t *l); struct jk_handler; typedef struct jk_handler jk_handler_t; struct jk_handler { int (*init)( jk_worker_t *w ); }; #ifdef __cplusplus } #endif /* __cplusplus */ #endif
-- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>