costin 01/11/20 08:58:47 Modified: jk/native/common jk_ajp_common.h jk_ajp_common.c jk_ajp14_worker.c jk_ajp14.h jk_ajp13_worker.c Removed: jk/native/common jk_ajp13.c jk_ajp13.h Log: Use the same header for ajp13 and ajp14. Move the remaining 'ajp13 specific' code in ajp_common - the 'base' protocol supported by both ajp13 and 14. The idea is to be able to use a single codebase and worker. User can configure the worker to use the new 14 APIs or stay in 'compatibility' mode. ( this will happen later - now we still use 2 different workers ) Revision Changes Path 1.12 +69 -3 jakarta-tomcat-connectors/jk/native/common/jk_ajp_common.h Index: jk_ajp_common.h =================================================================== RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native/common/jk_ajp_common.h,v retrieving revision 1.11 retrieving revision 1.12 diff -u -r1.11 -r1.12 --- jk_ajp_common.h 2001/10/09 18:07:37 1.11 +++ jk_ajp_common.h 2001/11/20 16:58:46 1.12 @@ -59,7 +59,7 @@ * Description: common stuff for bi-directional protocol ajp13/ajp14. * * Author: Gal Shachor <[EMAIL PROTECTED]> * * Author: Henri Gomez <[EMAIL PROTECTED]> * - * Version: $Revision: 1.11 $ * + * Version: $Revision: 1.12 $ * ***************************************************************************/ #ifndef JK_AJP_COMMON_H @@ -216,7 +216,70 @@ #define AJP_HEADER_SZ_LEN (2) #define CHUNK_BUFFER_PAD (12) +#define AJP13_PROTO 13 +#define AJP13_WS_HEADER 0x1234 +#define AJP13_SW_HEADER 0x4142 /* 'AB' */ + +#define AJP13_DEF_HOST ("localhost") +#define AJP13_DEF_PORT (8009) +#define AJP13_READ_BUF_SIZE (8*1024) +#define AJP13_DEF_CACHE_SZ (1) +#define JK_INTERNAL_ERROR (-2) +#define JK_FATAL_ERROR (-3) +#define JK_CLIENT_ERROR (-4) +#define AJP13_MAX_SEND_BODY_SZ (DEF_BUFFER_SZ - 6) +/* + * Message does not have a response (for example, JK_AJP13_END_RESPONSE) + */ +#define JK_AJP13_ERROR -1 +/* + * Message does not have a response (for example, JK_AJP13_END_RESPONSE) + */ +#define JK_AJP13_NO_RESPONSE 0 +/* + * Message have a response. + */ +#define JK_AJP13_HAS_RESPONSE 1 + +/* + * Forward a request from the web server to the servlet container. + */ +#define JK_AJP13_FORWARD_REQUEST (unsigned char)2 + +/* + * Write a body chunk from the servlet container to the web server + */ +#define JK_AJP13_SEND_BODY_CHUNK (unsigned char)3 + +/* + * Send response headers from the servlet container to the web server. + */ +#define JK_AJP13_SEND_HEADERS (unsigned char)4 + +/* + * Marks the end of response. + */ +#define JK_AJP13_END_RESPONSE (unsigned char)5 + +/* + * Marks the end of response. + */ +#define JK_AJP13_GET_BODY_CHUNK (unsigned char)6 + +/* + * Asks the container to shutdown + */ +#define JK_AJP13_SHUTDOWN (unsigned char)7 + +/* + * Functions + */ +int ajp13_marshal_shutdown_into_msgb(jk_msg_buf_t *msg, + jk_pool_t *p, + jk_logger_t *l); + + struct jk_res_data { int status; const char *msg; @@ -253,9 +316,12 @@ unsigned ep_cache_sz; ajp_endpoint_t **ep_cache; - int proto; /* PROTOCOL USED AJP13/AJP14 */ + /* PROTOCOL USED AJP13/AJP14 + XXX "version" - the API version to use + */ + int proto; - jk_login_service_t *login; + jk_login_service_t *login; jk_worker_t worker; 1.20 +31 -37 jakarta-tomcat-connectors/jk/native/common/jk_ajp_common.c Index: jk_ajp_common.c =================================================================== RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native/common/jk_ajp_common.c,v retrieving revision 1.19 retrieving revision 1.20 diff -u -r1.19 -r1.20 --- jk_ajp_common.c 2001/11/17 06:08:20 1.19 +++ jk_ajp_common.c 2001/11/20 16:58:46 1.20 @@ -59,15 +59,14 @@ * Description: common stuff for bi-directional protocols ajp13/ajp14. * * Author: Gal Shachor <[EMAIL PROTECTED]> * * Author: Henri Gomez <[EMAIL PROTECTED]> * - * Version: $Revision: 1.19 $ * + * Version: $Revision: 1.20 $ * ***************************************************************************/ #include "jk_global.h" #include "jk_util.h" -#include "jk_ajp13.h" -#include "jk_ajp14.h" #include "jk_ajp_common.h" +#include "jk_ajp14.h" #include "jk_connect.h" #include "jk_channel.h" #include "jk_env.h" @@ -408,6 +407,28 @@ return JK_TRUE; } +int ajp13_marshal_shutdown_into_msgb(jk_msg_buf_t *msg, + jk_pool_t *p, + jk_logger_t *l) +{ + jk_log(l, JK_LOG_DEBUG, "Into ajp13_marshal_shutdown_into_msgb\n"); + + /* To be on the safe side */ + jk_b_reset(msg); + + /* + * Just a single byte with s/d command. + */ + if (jk_b_append_byte(msg, JK_AJP13_SHUTDOWN)) { + jk_log(l, JK_LOG_ERROR, "ajp13_marshal_shutdown_into_msgb: " + "Error appending shutdown message\n"); + return JK_FALSE; + } + + return JK_TRUE; +} + + /* AJPV13_RESPONSE/AJPV14_RESPONSE:= response_prefix (2) @@ -616,16 +637,8 @@ jk_msg_buf_t *msg, jk_logger_t *l) { - if (ae->proto == AJP13_PROTO) { - jk_b_end(msg, AJP13_WS_HEADER); - jk_dump_buff(l, JK_LOG_DEBUG, "sending to ajp13", msg); - } else if (ae->proto == AJP14_PROTO) { - jk_b_end(msg, AJP14_WS_HEADER); - jk_dump_buff(l, JK_LOG_DEBUG, "sending to ajp14", msg); - } else { - jk_log(l, JK_LOG_ERROR, "In jk_endpoint_t::ajp_connection_tcp_send_message, unknown protocol %d, supported are AJP13/AJP14\n", ae->proto); - return JK_FALSE; - } + jk_b_end(msg, AJP13_WS_HEADER); + jk_dump_buff(l, JK_LOG_DEBUG, "sending to ajp13", msg); #ifdef CHANNEL { int err; @@ -682,30 +695,11 @@ header = ((unsigned int)head[0] << 8) | head[1]; - if (ae->proto == AJP13_PROTO) { - if (header != AJP13_SW_HEADER) { - if (header == AJP14_SW_HEADER) { - jk_log(l, JK_LOG_ERROR, "ajp_connection_tcp_get_message:" - " Error - received AJP14 reply on an AJP13 connection\n"); - } else { - jk_log(l, JK_LOG_ERROR, "ajp_connection_tcp_get_message:" - "Error - Wrong message format 0x%04x\n", header); - } - return JK_FALSE; - } - } else if (ae->proto == AJP14_PROTO) { - if (header != AJP14_SW_HEADER) { - if (header == AJP13_SW_HEADER) { - jk_log(l, JK_LOG_ERROR, "ajp_connection_tcp_get_message:" - " Error - received AJP13 reply on an AJP14 connection\n"); - } else { - jk_log(l, JK_LOG_ERROR, "ajp_connection_tcp_get_message:" - "Error - Wrong message format 0x%04x\n", header); - } - - return JK_FALSE; - } - } + if (header != AJP13_SW_HEADER) { + jk_log(l, JK_LOG_ERROR, "ajp_connection_tcp_get_message:" + "Error - Wrong message format 0x%04x\n", header); + return JK_FALSE; + } msglen = ((head[2]&0xff)<<8); msglen += (head[3] & 0xFF); 1.14 +4 -4 jakarta-tomcat-connectors/jk/native/common/jk_ajp14_worker.c Index: jk_ajp14_worker.c =================================================================== RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native/common/jk_ajp14_worker.c,v retrieving revision 1.13 retrieving revision 1.14 diff -u -r1.13 -r1.14 --- jk_ajp14_worker.c 2001/11/16 22:59:06 1.13 +++ jk_ajp14_worker.c 2001/11/20 16:58:46 1.14 @@ -58,15 +58,15 @@ /*************************************************************************** * Description: AJP14 next generation Bi-directional protocol. * * Author: Henri Gomez <[EMAIL PROTECTED]> * - * Version: $Revision: 1.13 $ * + * Version: $Revision: 1.14 $ * ***************************************************************************/ #include "jk_context.h" #include "jk_pool.h" #include "jk_util.h" #include "jk_msg_buff.h" -#include "jk_ajp13.h" -#include "jk_ajp14.h" +#include "jk_ajp_common.h" +#include "jk_ajp14.h" #include "jk_logger.h" #include "jk_service.h" @@ -212,7 +212,7 @@ if (ajp14_marshal_login_comp_into_msgb(msg, jl, l) != JK_TRUE) return JK_FALSE; - + if (ajp_connection_tcp_send_message(ae, msg, l) != JK_TRUE) return JK_FALSE; 1.7 +1 -4 jakarta-tomcat-connectors/jk/native/common/jk_ajp14.h Index: jk_ajp14.h =================================================================== RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native/common/jk_ajp14.h,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- jk_ajp14.h 2001/06/29 14:53:14 1.6 +++ jk_ajp14.h 2001/11/20 16:58:46 1.7 @@ -58,7 +58,7 @@ /*************************************************************************** * Description: Next generation bi-directional protocol handler. * * Author: Henri Gomez <[EMAIL PROTECTED]> * - * Version: $Revision: 1.6 $ * + * Version: $Revision: 1.7 $ * ***************************************************************************/ #ifndef JK_AJP14_H #define JK_AJP14_H @@ -71,9 +71,6 @@ #endif /* __cplusplus */ #define AJP14_PROTO 14 - -#define AJP14_WS_HEADER 0x1235 -#define AJP14_SW_HEADER 0x1235 /* AJP14 use now the same header in both directions */ #define AJP14_DEF_HOST ("localhost") #define AJP14_DEF_PORT (8011) 1.9 +1 -2 jakarta-tomcat-connectors/jk/native/common/jk_ajp13_worker.c Index: jk_ajp13_worker.c =================================================================== RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native/common/jk_ajp13_worker.c,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- jk_ajp13_worker.c 2001/11/16 22:59:06 1.8 +++ jk_ajp13_worker.c 2001/11/20 16:58:46 1.9 @@ -60,14 +60,13 @@ * Author: Costin <[EMAIL PROTECTED]> * * Author: Gal Shachor <[EMAIL PROTECTED]> * * Author: Henri Gomez <[EMAIL PROTECTED]> * - * Version: $Revision: 1.8 $ * + * Version: $Revision: 1.9 $ * ***************************************************************************/ #include "jk_pool.h" #include "jk_util.h" #include "jk_msg_buff.h" #include "jk_ajp_common.h" -#include "jk_ajp13.h" #include "jk_logger.h" int JK_METHOD ajp13_worker_factory(jk_worker_t **w,
-- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>