--- parser3/src/targets/cgi/parser3.C 2001/11/05 11:46:30 1.128 +++ parser3/src/targets/cgi/parser3.C 2001/11/21 08:34:43 1.142 @@ -4,7 +4,7 @@ Copyright(c) 2001 ArtLebedev Group(http://www.artlebedev.com) Author: Alexander Petrosyan (http://paf.design.ru) - $Id: parser3.C,v 1.128 2001/11/05 11:46:30 paf Exp $ + $Id: parser3.C,v 1.142 2001/11/21 08:34:43 paf Exp $ */ #include "pa_config_includes.h" @@ -13,6 +13,10 @@ # include #endif +#if _MSC_VER +# include +#endif + #include "pa_sapi.h" #include "classes.h" #include "pa_common.h" @@ -110,11 +114,40 @@ void SAPI::log(Pool& , const char *fmt, } void SAPI::die(const char *fmt, ...) { +#ifdef DEBUG_POOL_MALLOC + extern void log_pool_stats(Pool& pool); + log_pool_stats(pool); +#endif + + // log + + // logging is more important than user + // she can cancel download, we'd get SIG_PIPE, + // nothing would be logged then va_list args; va_start(args,fmt); ::log(fmt, args); va_end(args); + // inform user + + char body[MAX_STRING]; + int content_length=vsnprintf(body, MAX_STRING, fmt, args); + + // prepare header + // let's be honest, that's bad we couldn't produce valid output + SAPI::add_header_attribute(pool, "status", "500"); + SAPI::add_header_attribute(pool, "content-type", "text/plain"); + char content_length_cstr[MAX_NUMBER]; + snprintf(content_length_cstr, MAX_NUMBER, "%u", content_length); + SAPI::add_header_attribute(pool, "content-length", content_length_cstr); + + // send header + SAPI::send_header(pool); + + // body + SAPI::send_body(pool, body, content_length); + exit(1); } @@ -127,7 +160,7 @@ size_t SAPI::read_post(Pool& , char *buf do { int chunk_size=read(fileno(stdin), buf+read_size, min(READ_POST_CHUNK_SIZE, max_bytes-read_size)); - if(chunk_size<0) + if(chunk_size<=0) break; read_size+=chunk_size; } while(read_size"); +#endif } @@ -431,5 +465,5 @@ int main(int argc, char *argv[]) { if(!cgi) SAPI::send_body(pool, "\n", 1); #endif - return result; + return 0; }