--- parser3/src/targets/isapi/parser3isapi.C 2004/02/11 15:33:17 1.87 +++ parser3/src/targets/isapi/parser3isapi.C 2004/07/26 10:44:21 1.91 @@ -5,7 +5,7 @@ Author: Alexandr Petrosian (http://paf.design.ru) */ -static const char * const IDENT_PARSER3ISAPI_C="$Date: 2004/02/11 15:33:17 $"; +static const char * const IDENT_PARSER3ISAPI_C="$Date: 2004/07/26 10:44:21 $"; #ifndef _MSC_VER # error compile ISAPI module with MSVC [no urge for now to make it autoconf-ed (PAF)] @@ -93,14 +93,14 @@ void SAPI::die(const char* fmt, ...) { va_list args; va_start(args, fmt); ::abort(fmt, args); - va_end(args); +// va_end(args); } void SAPI::abort(const char* fmt, ...) { va_list args; va_start(args, fmt); ::abort(fmt, args); - va_end(args); +// va_end(args); } char* SAPI::get_env(SAPI_Info& SAPI_info, const char* name) { @@ -147,7 +147,7 @@ const char* const *SAPI::environment(SAP // we know this buf is writable char* all_http_vars=SAPI::get_env(info, "ALL_HTTP"); const int http_var_count=grep_char(all_http_vars, '\n')+1/*\n for theoretical(never saw) this \0*/; - + const char* *result=new const char*[IIS51var_count+http_var_count+1/*0*/]; const char* *cur=result; @@ -243,10 +243,12 @@ void SAPI::send_header(SAPI_Info& SAPI_i HSE_REQ_SEND_RESPONSE_HEADER_EX, &header_info, NULL, NULL); } -void SAPI::send_body(SAPI_Info& SAPI_info, const void *buf, size_t size) { +size_t SAPI::send_body(SAPI_Info& SAPI_info, const void *buf, size_t size) { DWORD num_bytes=size; - SAPI_info.lpECB->WriteClient(SAPI_info.lpECB->ConnID, - const_cast(buf), &num_bytes, HSE_IO_SYNC); + if(!SAPI_info.lpECB->WriteClient(SAPI_info.lpECB->ConnID, + const_cast(buf), &num_bytes, HSE_IO_SYNC)) + return 0; + return (size_t)num_bytes; } @@ -258,7 +260,7 @@ static bool parser_init() { try { // init socks - pa_init_socks(); + pa_socks_init(); // init global variables pa_globals_init(); @@ -272,6 +274,14 @@ static bool parser_init() { } } +static void parser_done() { + // finalize global variables + pa_globals_done(); + + // + pa_socks_done(); +} + /// ISAPI // BOOL WINAPI GetExtensionVersion(HSE_VERSION_INFO *pVer) { pVer->dwExtensionVersion = HSE_VERSION; @@ -279,6 +289,15 @@ BOOL WINAPI GetExtensionVersion(HSE_VERS pVer->lpszExtensionDesc[HSE_MAX_EXT_DLL_NAME_LEN-1]=0; return parser_init(); } +// dwFlags & HSE_TERM_MUST_UNLOAD means we can't return false +BOOL WINAPI TerminateExtension( + DWORD /*dwFlags*/ +) +{ + parser_done(); + + return TRUE; +} /** ISAPI // main workhorse @@ -293,6 +312,16 @@ BOOL WINAPI GetExtensionVersion(HSE_VERS */ void real_parser_handler(SAPI_Info& SAPI_info, bool header_only) { + // collect garbage from prev request +#ifndef PA_DEBUG_DISABLE_GC + { + int saved=GC_dont_gc; + GC_dont_gc=0; + GC_gcollect(); + GC_dont_gc=saved; + } +#endif + SAPI_info.header=new String; LPEXTENSION_CONTROL_BLOCK lpECB=SAPI_info.lpECB;