cvs commit: jakarta-tomcat-connectors/jk/native/common jk_ajp14_worker.c
mturk 2004/11/11 09:52:04 Modified:jk/native/common jk_ajp14_worker.c Log: Add new trace macros and clean up some log messages. Revision ChangesPath 1.22 +92 -45 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.21 retrieving revision 1.22 diff -u -r1.21 -r1.22 --- jk_ajp14_worker.c 8 Oct 2004 07:50:39 - 1.21 +++ jk_ajp14_worker.c 11 Nov 2004 17:52:04 - 1.22 @@ -47,46 +47,53 @@ char *buf; #ifndef TESTME +JK_TRACE_ENTER(l); ajp14_marshal_context_query_into_msgb(msg, we-virtual, l); -jk_log(l, JK_LOG_DEBUG, Into ajp14:discovery - send query\n); +jk_log(l, JK_LOG_DEBUG, send query\n); -if (ajp_connection_tcp_send_message(ae, msg, l) != JK_TRUE) +if (ajp_connection_tcp_send_message(ae, msg, l) != JK_TRUE) { +JK_TRACE_EXIT(l); return JK_FALSE; - -jk_log(l, JK_LOG_DEBUG, Into ajp14:discovery - wait context reply\n); +} +jk_log(l, JK_LOG_DEBUG, wait context reply\n); jk_b_reset(msg); -if (ajp_connection_tcp_get_message(ae, msg, l) != JK_TRUE) +if (ajp_connection_tcp_get_message(ae, msg, l) != JK_TRUE) { +JK_TRACE_EXIT(l); return JK_FALSE; - +} if ((cmd = jk_b_get_byte(msg)) != AJP14_CONTEXT_INFO_CMD) { jk_log(l, JK_LOG_ERROR, - Error ajp14:discovery - awaited command %d, received %d\n, + awaited command %d, received %d\n, AJP14_CONTEXT_INFO_CMD, cmd); +JK_TRACE_EXIT(l); return JK_FALSE; } if (context_alloc(c, we-virtual) != JK_TRUE) { jk_log(l, JK_LOG_ERROR, - Error ajp14:discovery - can't allocate context room\n); + can't allocate context room\n); +JK_TRACE_EXIT(l); return JK_FALSE; } if (ajp14_unmarshal_context_info(msg, c, l) != JK_TRUE) { jk_log(l, JK_LOG_ERROR, - Error ajp14:discovery - can't get context reply\n); + can't get context reply\n); +JK_TRACE_EXIT(l); return JK_FALSE; } -jk_log(l, JK_LOG_DEBUG, Into ajp14:discovery - received context\n); +jk_log(l, JK_LOG_DEBUG, received context\n); buf = malloc(MAX_URI_SIZE); /* Really a very long URI */ if (!buf) { -jk_log(l, JK_LOG_ERROR, Error ajp14:discovery - can't alloc buf\n); +jk_log(l, JK_LOG_ERROR, can't malloc buf\n); +JK_TRACE_EXIT(l); return JK_FALSE; } @@ -101,7 +108,7 @@ #endif jk_log(l, JK_LOG_INFO, - Into ajp14:discovery - worker %s will handle uri %s in context %s [%s]\n, + worker %s will handle uri %s in context %s [%s]\n, ae-worker-name, ci-uris[j], ci-cbase, buf); uri_worker_map_add(we-uri_to_worker, buf, ae-worker-name, l); @@ -122,6 +129,7 @@ #endif +JK_TRACE_EXIT(l); return JK_TRUE; } @@ -137,47 +145,55 @@ int cmd; jk_login_service_t *jl = ae-worker-login; +JK_TRACE_ENTER(l); ajp14_marshal_login_init_into_msgb(msg, jl, l); -jk_log(l, JK_LOG_DEBUG, Into ajp14:logon - send init\n); +jk_log(l, JK_LOG_DEBUG, send init\n); -if (ajp_connection_tcp_send_message(ae, msg, l) != JK_TRUE) +if (ajp_connection_tcp_send_message(ae, msg, l) != JK_TRUE) { +JK_TRACE_EXIT(l); return JK_FALSE; - -jk_log(l, JK_LOG_DEBUG, Into ajp14:logon - wait init reply\n); +} +jk_log(l, JK_LOG_DEBUG, wait init reply\n); jk_b_reset(msg); -if (ajp_connection_tcp_get_message(ae, msg, l) != JK_TRUE) +if (ajp_connection_tcp_get_message(ae, msg, l) != JK_TRUE) { +JK_TRACE_EXIT(l); return JK_FALSE; - +} if ((cmd = jk_b_get_byte(msg)) != AJP14_LOGSEED_CMD) { jk_log(l, JK_LOG_ERROR, - Error ajp14:logon: awaited command %d, received %d\n, + awaited command %d, received %d\n, AJP14_LOGSEED_CMD, cmd); +JK_TRACE_EXIT(l); return JK_FALSE; } -if (ajp14_unmarshal_login_seed(msg, jl, l) != JK_TRUE) +if (ajp14_unmarshal_login_seed(msg, jl, l) != JK_TRUE) { +JK_TRACE_EXIT(l); return JK_FALSE; - -jk_log(l, JK_LOG_DEBUG, Into ajp14:logon - received entropy %s\n, +} +jk_log(l, JK_LOG_DEBUG, received entropy %s\n, jl-entropy); ajp14_compute_md5(jl, l); -if (ajp14_marshal_login_comp_into_msgb(msg, jl, l) != JK_TRUE) +if
cvs commit: jakarta-tomcat-connectors/jk/native/common jk_ajp14_worker.c
mturk 2004/10/08 00:18:04 Modified:jk/native/common jk_ajp14_worker.c Log: Comment the login service for now. Revision ChangesPath 1.20 +4 -1 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.19 retrieving revision 1.20 diff -u -r1.19 -r1.20 --- jk_ajp14_worker.c 24 Feb 2004 08:45:48 - 1.19 +++ jk_ajp14_worker.c 8 Oct 2004 07:18:04 - 1.20 @@ -39,7 +39,10 @@ { int cmd; int i,j; +#if 0 +/* Not used for now */ jk_login_service_t *jl = ae-worker-login; +#endif jk_context_item_t *ci; jk_context_t*c; char*buf; - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: jakarta-tomcat-connectors/jk/native/common jk_ajp14_worker.c
costin 01/11/26 09:06:05 Modified:jk/native/common jk_ajp14_worker.c Log: Move discovery to the separate handler. Make sure it works in 'backward compatibility' mode if no secret is set. Revision ChangesPath 1.15 +135 -298 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.14 retrieving revision 1.15 diff -u -r1.14 -r1.15 --- jk_ajp14_worker.c 2001/11/20 16:58:46 1.14 +++ jk_ajp14_worker.c 2001/11/26 17:06:05 1.15 @@ -55,12 +55,15 @@ * * * = */ -/*** - * Description: AJP14 next generation Bi-directional protocol. * - * Author: Henri Gomez [EMAIL PROTECTED] * - * Version: $Revision: 1.14 $ * - ***/ +/** + * Description: AJP14 next generation Bi-directional protocol. + * Backward compatible with Ajp13 + * Author: Henri Gomez [EMAIL PROTECTED] + * Author: Costin [EMAIL PROTECTED] + * Author: Gal Shachor [EMAIL PROTECTED] + */ +#include jk_global.h #include jk_context.h #include jk_pool.h #include jk_util.h @@ -74,237 +77,55 @@ const char *name, jk_logger_t *l); -#ifdef WIN32 -/* define snprint to match windows version */ -#define snprintf _snprintf -#endif - -/* - * AJP14 Autoconf Phase - * - * CONTEXT QUERY / REPLY - */ - -#define MAX_URI_SIZE512 - -static int handle_discovery(ajp_endpoint_t *ae, -jk_worker_env_t *we, -jk_msg_buf_t*msg, -jk_logger_t *l) -{ -int cmd; -int i,j; -jk_login_service_t *jl = ae-worker-login; -jk_context_item_t *ci; -jk_context_t*c; -char*buf; - -#ifndef TESTME - -ajp14_marshal_context_query_into_msgb(msg, we-virtual, l); - -jk_log(l, JK_LOG_DEBUG, Into ajp14:discovery - send query\n); - -if (ajp_connection_tcp_send_message(ae, msg, l) != JK_TRUE) -return JK_FALSE; - -jk_log(l, JK_LOG_DEBUG, Into ajp14:discovery - wait context reply\n); - -jk_b_reset(msg); - -if (ajp_connection_tcp_get_message(ae, msg, l) != JK_TRUE) -return JK_FALSE; - -if ((cmd = jk_b_get_byte(msg)) != AJP14_CONTEXT_INFO_CMD) { -jk_log(l, JK_LOG_ERROR, Error ajp14:discovery - awaited command %d, received %d\n, AJP14_CONTEXT_INFO_CMD, cmd); -return JK_FALSE; -} - -if (context_alloc(c, we-virtual) != JK_TRUE) { -jk_log(l, JK_LOG_ERROR, Error ajp14:discovery - can't allocate context room\n); -return JK_FALSE; -} - -if (ajp14_unmarshal_context_info(msg, c, l) != JK_TRUE) { -jk_log(l, JK_LOG_ERROR, Error ajp14:discovery - can't get context reply\n); -return JK_FALSE; -} - -jk_log(l, JK_LOG_DEBUG, Into ajp14:discovery - received context\n); - -buf = malloc(MAX_URI_SIZE); /* Really a very long URI */ - -if (! buf) { -jk_log(l, JK_LOG_ERROR, Error ajp14:discovery - can't alloc buf\n); -return JK_FALSE; -} - -for (i = 0; i c-size; i++) { -ci = c-contexts[i]; -for (j = 0; j ci-size; j++) { - -#ifndef USE_SPRINTF -snprintf(buf, MAX_URI_SIZE - 1, /%s/%s, ci-cbase, ci-uris[j]); -#else -sprintf(buf, /%s/%s, ci-cbase, ci-uris[j]); -#endif - -jk_log(l, JK_LOG_INFO, Into ajp14:discovery - worker %s will handle uri %s in context %s [%s]\n, -ae-worker-name, ci-uris[j], ci-cbase, buf); - -uri_worker_map_add(we-uri_to_worker, buf, ae-worker-name, l); -} -} - -free(buf); -context_free(c); - -#else - -uri_worker_map_add(we-uri_to_worker, /examples/servlet/*, ae-worker-name, l); -uri_worker_map_add(we-uri_to_worker, /examples/*.jsp, ae-worker-name, l); -uri_worker_map_add(we-uri_to_worker, /examples/*.gif, ae-worker-name, l); - -#endif - -return JK_TRUE; -} - -/* - * AJP14 Logon Phase - * - * INIT + REPLY / NEGO + REPLY - */ - -static int handle_logon(ajp_endpoint_t *ae, -
cvs commit: jakarta-tomcat-connectors/jk/native/common jk_ajp14_worker.c
jfclere 01/07/06 09:27:35 Modified:jk/native/common jk_ajp14_worker.c Log: Arrange C++ comment. Revision ChangesPath 1.10 +2 -2 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.9 retrieving revision 1.10 diff -u -r1.9 -r1.10 --- jk_ajp14_worker.c 2001/07/02 21:17:07 1.9 +++ jk_ajp14_worker.c 2001/07/06 16:27:35 1.10 @@ -58,7 +58,7 @@ /*** * Description: AJP14 next generation Bi-directional protocol. * * Author: Henri Gomez [EMAIL PROTECTED] * - * Version: $Revision: 1.9 $ * + * Version: $Revision: 1.10 $ * ***/ #include jk_context.h @@ -406,7 +406,7 @@ memset(aw-login, 0, sizeof(jk_login_service_t)); aw-login-negociation = (AJP14_CONTEXT_INFO_NEG | AJP14_PROTO_SUPPORT_AJP14_NEG); - aw-login-web_server_name = NULL; // must be set in init + aw-login-web_server_name = NULL; /* must be set in init */ aw-ep_cache_sz= 0; aw-ep_cache = NULL;
cvs commit: jakarta-tomcat-connectors/jk/native/common jk_ajp14_worker.c
hgomez 01/07/02 14:17:10 Modified:jk/native/common jk_ajp14_worker.c Log: At least, the discovery (autoconf) is implemented Will have to focus next on where to get virtuals J-T-C peoples don't forget about SSL case which is also a virtual (host:443) Revision ChangesPath 1.9 +192 -85 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.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- jk_ajp14_worker.c 2001/06/23 16:04:12 1.8 +++ jk_ajp14_worker.c 2001/07/02 21:17:07 1.9 @@ -58,115 +58,103 @@ /*** * Description: AJP14 next generation Bi-directional protocol. * * Author: Henri Gomez [EMAIL PROTECTED] * - * Version: $Revision: 1.8 $ * + * Version: $Revision: 1.9 $ * ***/ #include jk_context.h #include jk_ajp14_worker.h -/* Method */ -static int JK_METHOD validate(jk_worker_t *pThis, - jk_map_t*props, - jk_worker_env_t *we, - jk_logger_t *l) -{ - ajp_worker_t *aw; - char * secret_key; -if (ajp_validate(pThis, props, we, l, AJP14_PROTO) == JK_FALSE) - return JK_FALSE; +/* + * AJP14 Autoconf Phase + * + * CONTEXT QUERY / REPLY + */ - aw = pThis-worker_private; +#define MAX_URI_SIZE512 - secret_key = jk_get_worker_secret_key(props, aw-name); +static int handle_discovery(ajp_endpoint_t *ae, +jk_worker_env_t *we, +jk_msg_buf_t*msg, +jk_logger_t *l) +{ +int cmd; +int i,j; +jk_login_service_t *jl = ae-worker-login; +jk_context_item_t *ci; +jk_context_t*c; +char*old; +char*buf; - if ((!secret_key) || (!strlen(secret_key))) { - jk_log(l, JK_LOG_ERROR, validate error, empty or missing secretkey\n); - return JK_FALSE; - } +#ifndef TESTME - /* jk_log(l, JK_LOG_DEBUG, Into ajp14:validate - secret_key=%s\n, secret_key); */ - return JK_TRUE; -} +ajp14_marshal_context_query_into_msgb(msg, we-virtual, l); -static int JK_METHOD get_endpoint(jk_worker_t*pThis, - jk_endpoint_t **pend, - jk_logger_t*l) -{ -return (ajp_get_endpoint(pThis, pend, l, AJP14_PROTO)); -} +jk_log(l, JK_LOG_DEBUG, Into ajp14:discovery - send query\n); -static int JK_METHOD init(jk_worker_t *pThis, - jk_map_t*props, - jk_worker_env_t *we, - jk_logger_t *l) -{ - ajp_worker_t *aw; - ajp_endpoint_t *ae; - jk_endpoint_t *je; - /*char *secret_key; unused */ +if (ajp_connection_tcp_send_message(ae, msg, l) != JK_TRUE) +return JK_FALSE; - if (ajp_init(pThis, props, we, l, AJP14_PROTO) == JK_FALSE) - return JK_FALSE; +jk_log(l, JK_LOG_DEBUG, Into ajp14:discovery - wait context reply\n); - aw = pThis-worker_private; +jk_b_reset(msg); - /* Set Secret Key (used at logon time) */ - aw-login-secret_key = strdup(jk_get_worker_secret_key(props, aw-name)); +if (ajp_connection_tcp_get_message(ae, msg, l) != JK_TRUE) +return JK_FALSE; - if (aw-login-secret_key == NULL) { - jk_log(l, JK_LOG_ERROR, can't malloc secret_key\n); - return JK_FALSE; - } +if ((cmd = jk_b_get_byte(msg)) != AJP14_CONTEXT_INFO_CMD) { +jk_log(l, JK_LOG_ERROR, Error ajp14:discovery - awaited command %d, received %d\n, AJP14_CONTEXT_INFO_CMD, cmd); +return JK_FALSE; +} - /* Set WebServerName (used at logon time) */ - aw-login-web_server_name = strdup(we-server_name); +if (context_alloc(c, we-virtual) != JK_TRUE) { +jk_log(l, JK_LOG_ERROR, Error ajp14:discovery - can't allocate context room\n); +return JK_FALSE; +} + +if (ajp14_unmarshal_context_info(msg, c, l) != JK_TRUE) { +jk_log(l, JK_LOG_ERROR, Error ajp14:discovery - can't get context reply\n); +return JK_FALSE; +} - if (aw-login-web_server_name == NULL) { -
cvs commit: jakarta-tomcat-connectors/jk/native/common jk_ajp14_worker.c
costin 01/06/23 09:04:12 Modified:jk/native/common jk_ajp14_worker.c Log: Small fix - if validation fails ( like I forgot to add the secret ), then destroy will try to free() a constant ( since strdup didn't happened ). We set it to null, the init will fail if the user doesn't specify a valid option. ( the stack trace was: #0 0x40095ce8 in pthread_mutex_lock () from /lib/libpthread.so.0 #1 0x401230a8 in free () from /lib/libc.so.6 #2 0x401d2364 in destroy (pThis=0xb414, l=0x8165df8) at ../common/jk_ajp14_worker.c:156 #3 0x401d56f8 in wc_create_worker (name=0x8168038 ajp14, init_data=0x81674f8, rc=0xb468, we=0x401e275c, l=0x8165df8) at ../common/jk_worker.c:170 #4 Revision ChangesPath 1.8 +2 -2 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.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- jk_ajp14_worker.c 2001/06/22 08:33:56 1.7 +++ jk_ajp14_worker.c 2001/06/23 16:04:12 1.8 @@ -58,7 +58,7 @@ /*** * Description: AJP14 next generation Bi-directional protocol. * * Author: Henri Gomez [EMAIL PROTECTED] * - * Version: $Revision: 1.7 $ * + * Version: $Revision: 1.8 $ * ***/ #include jk_context.h @@ -299,7 +299,7 @@ memset(aw-login, 0, sizeof(jk_login_service_t)); aw-login-negociation = (AJP14_CONTEXT_INFO_NEG | AJP14_PROTO_SUPPORT_AJP14_NEG); - aw-login-web_server_name = MyApache; + aw-login-web_server_name = NULL; // must be set in init aw-ep_cache_sz= 0; aw-ep_cache = NULL;
cvs commit: jakarta-tomcat-connectors/jk/native/common jk_ajp14_worker.c
hgomez 01/06/19 09:35:23 Modified:jk/native/common jk_ajp14_worker.c Log: Minor fixes. init info (web_server_name/secret_key) need to be stored locally (if not there're lost by pool activity) also correct logon phase (didn't get the cmd byte) Revision ChangesPath 1.6 +31 -3 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.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- jk_ajp14_worker.c 2001/06/18 14:15:27 1.5 +++ jk_ajp14_worker.c 2001/06/19 16:35:20 1.6 @@ -58,7 +58,7 @@ /*** * Description: AJP14 next generation Bi-directional protocol. * * Author: Henri Gomez [EMAIL PROTECTED] * - * Version: $Revision: 1.5 $ * + * Version: $Revision: 1.6 $ * ***/ #include jk_context.h @@ -111,10 +111,20 @@ aw = pThis-worker_private; /* Set Secret Key (used at logon time) */ - aw-login-secret_key = jk_get_worker_secret_key(props, aw-name); + aw-login-secret_key = strdup(jk_get_worker_secret_key(props, aw-name)); + if (aw-login-secret_key == NULL) { + jk_log(l, JK_LOG_ERROR, can't malloc secret_key\n); + return JK_FALSE; + } + /* Set WebServerName (used at logon time) */ - aw-login-web_server_name = we-server_name; + aw-login-web_server_name = strdup(we-server_name); + + if (aw-login-web_server_name == NULL) { + jk_log(l, JK_LOG_ERROR, can't malloc web_server\n); + return JK_FALSE; + } if (get_endpoint(pThis, je, l) == JK_FALSE) return JK_FALSE; @@ -140,6 +150,17 @@ ajp_worker_t *aw = (*pThis)-worker_private; if (aw-login) { + + if (aw-login-web_server_name) { + free(aw-login-web_server_name); + aw-login-web_server_name = NULL; + } + + if (aw-login-secret_key) { + free(aw-login-secret_key); + aw-login-secret_key = NULL; + } + free(aw-login); aw-login = NULL; } @@ -157,6 +178,8 @@ jk_msg_buf_t*msg, jk_logger_t *l) { + int cmd; + jk_login_service_t *jl = ae-worker-login; ajp14_marshal_login_init_into_msgb(msg, jl, l); @@ -169,6 +192,11 @@ jk_log(l, JK_LOG_DEBUG, Into ajp14:logon - wait init reply\n); jk_b_reset(msg); + + if ((cmd = jk_b_get_byte(msg)) != AJP14_LOGSEED_CMD) { + jk_log(l, JK_LOG_ERROR, Into ajp14:logon - awaited command %d, received command %d\n, AJP14_LOGSEED_CMD, cmd); + return JK_FALSE; + } if (ajp_connection_tcp_get_message(ae, msg, l) != JK_TRUE) return JK_FALSE;