--- parser3/src/targets/apache13/modules/extra/Attic/mod_parser3.C 2001/03/24 09:24:45 1.16 +++ parser3/src/targets/apache13/modules/extra/Attic/mod_parser3.C 2001/04/03 07:32:47 1.21 @@ -5,7 +5,7 @@ Author: Alexander Petrosyan (http://design.ru/paf) - $Id: mod_parser3.C,v 1.16 2001/03/24 09:24:45 paf Exp $ + $Id: mod_parser3.C,v 1.21 2001/04/03 07:32:47 paf Exp $ */ #include "httpd.h" @@ -133,13 +133,24 @@ void SAPI::send_header(Pool& pool) { ap_kill_timeout(r); } -void SAPI::send_body(Pool& pool, const char *buf, size_t size) { +void SAPI::send_body(Pool& pool, const void *buf, size_t size) { request_rec *r=static_cast(pool.context()); ap_hard_timeout("Send body", r); ap_rwrite(buf, size, r); ap_kill_timeout(r); } + +void SAPI::log(Pool& pool, const char *fmt, ...) { + request_rec *r=static_cast(pool.context()); + + va_list args; + va_start(args,fmt); + char buf[MAX_STRING]; + vsnprintf(buf, MAX_STRING, fmt, args); + ap_log_rerror(0, 0, APLOG_ERR | APLOG_NOERRNO, r, "%s", buf); + va_end(args); +} //@} /** @@ -166,20 +177,16 @@ static int parser_handler(request_rec *r // Request info Request::Info request_info; - request_info.document_root=(const char *) - ap_table_get(r->subprocess_env, "DOCUMENT_ROOT"); + request_info.document_root=SAPI::get_env(pool, "DOCUMENT_ROOT"); request_info.path_translated=r->filename; request_info.method=r->method; request_info.query_string=r->args; - request_info.uri=(const char *) - ap_table_get(r->subprocess_env, "REQUEST_URI"); - request_info.content_type=(const char *) - ap_table_get(r->subprocess_env, "CONTENT_TYPE"); - const char *content_length=(const char *) - ap_table_get(r->subprocess_env, "CONTENT_LENGTH"); + request_info.uri=SAPI::get_env(pool, "REQUEST_URI"); + request_info.content_type=SAPI::get_env(pool, "CONTENT_TYPE"); + const char *content_length=SAPI::get_env(pool, "CONTENT_LENGTH"); request_info.content_length=(content_length?atoi(content_length):0); - request_info.cookie=(const char *) - ap_table_get(r->subprocess_env, "HTTP_COOKIE"); + request_info.cookie=SAPI::get_env(pool, "HTTP_COOKIE"); + request_info.user_agent=SAPI::get_env(pool, "HTTP_USER_AGENT"); // prepare to process request Request request(pool, @@ -198,7 +205,14 @@ static int parser_handler(request_rec *r // successful finish } PCATCH(e) { // global problem + // don't allocate anything on pool here: + // possible pool' exception not catch-ed now + // and there could be out-of-memory exception const char *body=e.comment(); + // log it + SAPI::log(pool, "exception in request exception handler: %s", body); + + // int content_length=strlen(body); // prepare header @@ -275,18 +289,17 @@ static void setup_module_cells() { PTRY { // init global variables pa_globals_init(pool); - - //... } PCATCH(e) { // global problem - const char *body=e.comment(); - // TODO: somehow report that error + ap_log_error(APLOG_MARK, APLOG_EMERG, 0, + "setup_module_cells failed: ", e.comment()); + exit(1); } PEND_CATCH } static void parser_server_init(server_rec *s, pool *p) { #if MODULE_MAGIC_NUMBER >= 19980527 - ap_add_version_component("Parser/" PARSER_VERSION); + ap_add_version_component("Parser/"PARSER_VERSION); #endif /*