|
|
| version 1.331, 2020/12/15 20:57:56 | version 1.337, 2020/12/16 14:51:27 |
|---|---|
| Line 14 volatile const char * IDENT_PARSER3_C="$ | Line 14 volatile const char * IDENT_PARSER3_C="$ |
| #include "pa_common.h" | #include "pa_common.h" |
| #include "pa_request.h" | #include "pa_request.h" |
| #include "pa_version.h" | #include "pa_version.h" |
| #include "pa_threads.h" | |
| #include "pa_vconsole.h" | #include "pa_vconsole.h" |
| #include "pa_sapi_info.h" | #include "pa_sapi_info.h" |
| Line 58 static const char* filespec_4log = NULL; | Line 59 static const char* filespec_4log = NULL; |
| // SAPI | // SAPI |
| static void log(const char* fmt, va_list args) { | static void pa_log(const char* fmt, va_list args) { |
| bool opened=false; | bool opened=false; |
| FILE *f=0; | FILE *f=0; |
| Line 98 static void log(const char* fmt, va_list | Line 99 static void log(const char* fmt, va_list |
| time_t t=time(0); | time_t t=time(0); |
| if(const char* stamp=ctime(&t)) { // never saw that | if(const char* stamp=ctime(&t)) { // never saw that |
| if(size_t len=strlen(stamp)) // saw once stamp being ="" | if(size_t len=strlen(stamp)) // saw once stamp being ="" |
| fprintf(f, "[%.*s] [%u] ", (int)len-1, stamp, (unsigned int)getpid() ); | fprintf(f, "[%.*s] [%u] ", (int)len-1, stamp, (unsigned int)pa_get_thread_id() ); |
| } | } |
| // message | // message |
| Line 118 static void log(const char* fmt, va_list | Line 119 static void log(const char* fmt, va_list |
| fflush(f); | fflush(f); |
| } | } |
| #ifdef PA_DEBUG_CGI_ENTRY_EXIT | void pa_log(const char* fmt, ...) { |
| static void log(const char* fmt, ...) { | |
| va_list args; | va_list args; |
| va_start(args,fmt); | va_start(args,fmt); |
| log(fmt, args); | pa_log(fmt, args); |
| va_end(args); | va_end(args); |
| } | } |
| #endif | |
| // appends to parser3.log located next to the config file if openable, to stderr otherwize | // appends to parser3.log located next to the config file if openable, to stderr otherwize |
| void SAPI::log(SAPI_Info&, const char* fmt, ...) { | void SAPI::log(SAPI_Info&, const char* fmt, ...) { |
| va_list args; | va_list args; |
| va_start(args,fmt); | va_start(args,fmt); |
| ::log(fmt, args); | pa_log(fmt, args); |
| va_end(args); | va_end(args); |
| } | } |
| Line 140 void SAPI::die(const char* fmt, ...) { | Line 139 void SAPI::die(const char* fmt, ...) { |
| // logging first, first vsnprintf | // logging first, first vsnprintf |
| va_start(args,fmt); | va_start(args,fmt); |
| ::log(fmt, args); | pa_log(fmt, args); |
| va_end(args); | va_end(args); |
| // inform user, second vsnprintf | // inform user, second vsnprintf |
| Line 316 static void connection_handler(SAPI_Info | Line 315 static void connection_handler(SAPI_Info |
| try { | try { |
| memset(&request_info, 0, sizeof(request_info)); | memset(&request_info, 0, sizeof(request_info)); |
| connection.read_header(); | if(!connection.read_header()) |
| return; // ignore "void" connections | |
| info.populate_env(); | info.populate_env(); |
| char document_root_buf[MAX_STRING]; | char document_root_buf[MAX_STRING]; |
| Line 339 static void connection_handler(SAPI_Info | Line 339 static void connection_handler(SAPI_Info |
| r.core(config_filespec, strcasecmp(request_info.method, "HEAD")==0, String("httpd-main")); | r.core(config_filespec, strcasecmp(request_info.method, "HEAD")==0, String("httpd-main")); |
| } catch(const Exception& e) { // exception in connection handling or unhandled exception | } catch(const Exception& e) { // exception in connection handling or unhandled exception |
| SAPI::log(info, "%s", e.comment()); | SAPI::log(info, "%s", e.comment()); |
| SAPI::send_error(info, e.comment(), info.exception_http_status(e.type())); | const char *status = info.exception_http_status(e.type()); |
| if(status) | |
| SAPI::send_error(info, e.comment(), status); | |
| } | } |
| } | } |