hgomez 01/02/09 00:48:42 Modified: src/native/mod_jk/apache2.0 Makefile.linux mod_jk.c Log: mod_jk.c adapted to the lastest Apache 2.0 API Enjoy ! Revision Changes Path 1.5 +25 -26 jakarta-tomcat/src/native/mod_jk/apache2.0/Makefile.linux Index: Makefile.linux =================================================================== RCS file: /home/cvs/jakarta-tomcat/src/native/mod_jk/apache2.0/Makefile.linux,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- Makefile.linux 2000/12/20 19:32:42 1.4 +++ Makefile.linux 2001/02/09 08:48:41 1.5 @@ -1,38 +1,37 @@ ## You need to edit this file - configure later :-) -APACHE_HOME=/usr/local/apache2.0 -OS=linux - ## I assume this one is set up already # JAVA_HOME= - -## - -AP20_INCL=-I${APACHE_HOME}/include/apr -I${APACHE_HOME}/include/apr-util -I${APACHE_HOME}/include - -JAVA_INCL=-I${JAVA_HOME}/include -I${JAVA_HOME}/include/${OS} - -JAVA_LIB=-L${JAVA_HOME}/jre/lib/${ARCH} -L${JAVA_HOME}/lib/${ARCH}/native_threads - -CFLAGS=-DHAVE_CONFIG_H -g -fpic -DSHARED_MODULE -O2 -D_REENTRANT -pthread -DLINUX -Wall -DAPACHE2_SIGHACK - -SRCS=jk_ajp12_worker.c jk_connect.c jk_msg_buff.c jk_util.c jk_ajp13.c \ - jk_jni_worker.c jk_pool.c jk_worker.c jk_ajp13_worker.c jk_lb_worker.c \ - jk_sockbuf.c jk_map.c jk_uri_worker_map.c +OS=linux -OBJS=${patsubst %.c,%.o,${SRCS}} +JAVA_INCL=-I ${JAVA_HOME}/include -I ${JAVA_HOME}/include/${OS} +JAVA_LIB=-L ${JAVA_HOME}/jre/lib/${ARCH} -L ${JAVA_HOME}/lib/${ARCH}/native_threads -%.o: ../common/%.c - ${CC} -c ${CFLAGS} ${JAVA_INCL} ${AP20_INCL} $< -o $@ +# +# I've built a RPM, named apache2 (ftp://ftp.falsehope.com/home/gomez/apache2/), +# which postfix all apache2 stuff with 2, ie apxs = apxs2. +# It will allow to have both apache 1.3 and 2.0 the same time on the system +# +#ifndef APXS +APXS=/usr/sbin/apxs2 +#endif + +JK=../common +SRCS=${JK}/jk_ajp12_worker.c ${JK}/jk_connect.c ${JK}/jk_msg_buff.c ${JK}/jk_util.c ${JK}/jk_ajp13.c \ + ${JK}/jk_jni_worker.c ${JK}/jk_pool.c ${JK}/jk_worker.c ${JK}/jk_ajp13_worker.c ${JK}/jk_lb_worker.c \ + ${JK}/jk_sockbuf.c ${JK}/jk_map.c ${JK}/jk_uri_worker_map.c + +LSRCS=jk_ajp12_worker.c jk_connect.c jk_msg_buff.c jk_util.c jk_ajp13.c \ + jk_jni_worker.c jk_pool.c jk_worker.c jk_ajp13_worker.c jk_lb_worker.c \ + jk_sockbuf.c jk_map.c jk_uri_worker_map.c -.c.o: - ${CC} -c ${CFLAGS} ${JAVA_INCL} ${AP20_INCL} -I../common $< all: mod_jk.so -mod_jk.so: ${OBJS} mod_jk.o - $(CC) -shared -o mod_jk.so ${OBJS} mod_jk.o +mod_jk.so: + $(APXS) -I ${JK} ${JAVA_INCL} -c -o mod_jk.la mod_jk.c $(SRCS) + mv .libs/mod_jk.so . clean: - rm *.o *.so - + rm -f *.o *.so *.lo *.la *.slo ${JK}/*.o ${JK}/*.so ${JK}/*.lo ${JK}/*.la ${JK}/*.slo + rm -rf .libs 1.7 +80 -48 jakarta-tomcat/src/native/mod_jk/apache2.0/mod_jk.c Index: mod_jk.c =================================================================== RCS file: /home/cvs/jakarta-tomcat/src/native/mod_jk/apache2.0/mod_jk.c,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- mod_jk.c 2000/12/20 19:45:23 1.6 +++ mod_jk.c 2001/02/09 08:48:41 1.7 @@ -56,6 +56,7 @@ /*************************************************************************** * Description: Apache 2 plugin for Jakarta/Tomcat * * Author: Gal Shachor <[EMAIL PROTECTED]> * + * Henri Gomez <[EMAIL PROTECTED]> * * Version: $ $ * ***************************************************************************/ @@ -91,8 +92,10 @@ #define JK_MAGIC_TYPE ("application/x-jakarta-servlet") #define NULL_FOR_EMPTY(x) ((x && !strlen(x)) ? NULL : x) -module MODULE_VAR_EXPORT jk_module; +/* module MODULE_VAR_EXPORT jk_module; */ +AP_DECLARE_DATA module jk_module; + typedef struct { char *log_file; int log_level; @@ -328,10 +331,48 @@ REMOTE_HOST); s->remote_host = NULL_FOR_EMPTY(s->remote_host); - s->remote_addr = NULL_FOR_EMPTY(r->connection->remote_ip); - s->server_name = (r->hostname ? r->server->server_hostname : r->hostname); - s->server_port = r->server->port; + + jk_log(main_log, JK_LOG_DEBUG, + "agsp=%u agsn=%s hostn=%s shostn=%s cbsport=%d sport=%d \n", + ap_get_server_port( r ), + ap_get_server_name( r ), + r->hostname, + r->server->server_hostname, + r->connection->base_server->port, + r->server->port + ); + +#ifdef NOTNEEDEDFORNOW + /* Wrong: s->server_name = (char *)ap_get_server_name( r ); */ + s->server_name= (char *)(r->hostname ? r->hostname : + r->server->server_hostname); + + + s->server_port= htons( r->connection->local_addr.sin_port ); + /* Wrong: s->server_port = r->server->port; */ + + + /* Winners: htons( r->connection->local_addr.sin_port ) + (r->hostname ? r->hostname : + r->server->server_hostname), + */ + /* printf( "Port %u %u %u %s %s %s %d %d \n", + ap_get_server_port( r ), + htons( r->connection->local_addr.sin_port ), + ntohs( r->connection->local_addr.sin_port ), + ap_get_server_name( r ), + (r->hostname ? r->hostname : r->server->server_hostname), + r->hostname, + r->connection->base_server->port, + r->server->port + ); + */ +#else + s->server_name = (char *)ap_get_server_name( r ); + s->server_port = r->server->port; +#endif + s->server_software = ap_get_server_version(); s->method = (char *)r->method; @@ -403,7 +444,7 @@ * Add the new worker to the alias map. */ char *old; - map_put(conf->uri_to_context, context, worker, &old); + map_put(conf->uri_to_context, context, worker, (void **)&old); return NULL; } @@ -474,7 +515,20 @@ static int jk_handler(request_rec *r) { - const char *worker_name = apr_table_get(r->notes, JK_WORKER_ID); + const char *worker_name; + + if(strcmp(r->handler,JK_HANDLER)) /* not for me, try next handler */ + return DECLINED; + + if (1) + { + jk_server_conf_t *xconf = + (jk_server_conf_t *)ap_get_module_config(r->server->module_config, &jk_module); + jk_logger_t *xl = xconf->log ? xconf->log : main_log; + jk_log(xl, JK_LOG_DEBUG, "Into handler r->proxyreq=%d r->handler=%s r->notes=%d\n", r->proxyreq, r->handler, r->notes); + } + + worker_name = apr_table_get(r->notes, JK_WORKER_ID); /* If this is a proxy request, we'll notify an error */ if(r->proxyreq) { @@ -530,6 +584,18 @@ &s, l, &is_recoverable_error); + + if (s.content_read < s.content_length) { + /* Toss all further characters left to read fm client */ + char *buff = apr_palloc(r->pool, 2048); + if (buff != NULL) { + int rd; + while ((rd = ap_get_client_block(r, buff, 2048)) > 0) { + s.content_read += rd; + } + } + } + #ifndef REUSE_WORKER end->done(&end, l); #endif @@ -542,7 +608,7 @@ } } - return HTTP_INTERNAL_SERVER_ERROR; + return DECLINED; } static void *create_jk_config(apr_pool_t *p, server_rec *s) @@ -607,13 +673,10 @@ static void jk_child_init(apr_pool_t *pconf, server_rec *s) { - char *p = getenv("WAS_BORN_BY_APACHE"); jk_map_t *init_map = NULL; jk_server_conf_t *conf = (jk_server_conf_t *)ap_get_module_config(s->module_config, &jk_module); - fprintf(stdout, "jk_child_init %s\n", p ? p : "NULL"); fflush(stdout); - if(conf->log_file && conf->log_level >= 0) { if(!jk_open_file_logger(&(conf->log), conf->log_file, conf->log_level)) { conf->log = NULL; @@ -623,7 +686,6 @@ } if(!uri_worker_map_alloc(&(conf->uw_map), conf->uri_to_context, conf->log)) { - printf( "Memory error - uri worker alloc \n"); jk_error_exit(APLOG_MARK, APLOG_EMERG, s, "Memory error"); } @@ -644,18 +706,10 @@ server_rec *s) { if(!s->is_virtual) { - char *p = getenv("WAS_BORN_BY_APACHE"); jk_map_t *init_map = NULL; jk_server_conf_t *conf = (jk_server_conf_t *)ap_get_module_config(s->module_config, &jk_module); if(!conf->was_initialized) { - fprintf(stdout, "jk_post_config %s %s %d %d %s\n", - s->server_hostname, - s->server_admin, - s, - conf, - p ? p : "NULL"); fflush(stdout); - conf->was_initialized = JK_TRUE; if(conf->log_file && conf->log_level >= 0) { if(!jk_open_file_logger(&(conf->log), conf->log_file, conf->log_level)) { @@ -671,14 +725,10 @@ if(map_alloc(&init_map)) { if(map_read_properties(init_map, conf->worker_file)) { - if(!p) { - putenv("WAS_BORN_BY_APACHE=true"); - return; - } else { + ap_add_version_component(pconf, "mod_jk"); if(wc_open(init_map, conf->log)) { return; } - } } } @@ -711,39 +761,21 @@ static void jk_register_hooks(void) { -#ifdef WIN32 - ap_hook_post_config(jk_post_config, - NULL, - NULL, - AP_HOOK_MIDDLE); + ap_hook_handler(jk_handler, NULL, NULL, APR_HOOK_MIDDLE); + ap_hook_post_config(jk_post_config,NULL,NULL,APR_HOOK_MIDDLE); + ap_hook_child_init(jk_child_init,NULL,NULL,APR_HOOK_MIDDLE); + ap_hook_translate_name(jk_translate,NULL,NULL,APR_HOOK_FIRST); -#else - ap_hook_child_init(jk_child_init, - NULL, - NULL, - AP_HOOK_MIDDLE); -#endif - ap_hook_translate_name(jk_translate, - NULL, - NULL, - AP_HOOK_FIRST); } -static const handler_rec jk_handlers[] = +module AP_MODULE_DECLARE_DATA jk_module = { - { JK_MAGIC_TYPE, jk_handler }, - { JK_HANDLER, jk_handler }, - { NULL } -}; - -module MODULE_VAR_EXPORT jk_module = -{ STANDARD20_MODULE_STUFF, NULL, /* dir config creater */ NULL, /* dir merger --- default is to override */ create_jk_config, /* server config */ merge_jk_config, /* merge server config */ jk_cmds, /* command ap_table_t */ - jk_handlers, /* handlers */ jk_register_hooks /* register hooks */ }; + --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, email: [EMAIL PROTECTED]