--- parser3/src/targets/cgi/parser3.C 2026/10/05 17:50:18 1.375 +++ parser3/src/targets/cgi/parser3.C 2026/10/16 13:55:16 1.379 @@ -5,7 +5,7 @@ Authors: Konstantin Morshnev , Alexandr Petrosian */ -volatile const char * IDENT_PARSER3_C="$Id: parser3.C,v 1.375 2026/10/05 17:50:18 moko Exp $"; +volatile const char * IDENT_PARSER3_C="$Id: parser3.C,v 1.379 2026/10/16 13:55:16 moko Exp $"; #include "pa_config_includes.h" @@ -18,6 +18,7 @@ volatile const char * IDENT_PARSER3_C="$ #include "pa_vconsole.h" #include "pa_sapi_info.h" #include "pa_code_cache.h" +#include "pa_websocket.h" #ifdef _MSC_VER #include @@ -330,7 +331,7 @@ static void config_handler(SAPI_Info &in #ifdef CODE_CACHE Code_cache_manager::start(); #endif - r.core(config_filespec, false, String::Empty); + r.core(config_filespec, String::Empty); #ifdef CODE_CACHE Code_cache_manager::finish(r); #endif @@ -358,8 +359,10 @@ static void connection_handler(SAPI_Info // prepare to process request Request r(info, request_info, String::Language(String::L_HTML|String::L_OPTIMIZE_BIT)); + WebSocket websocket(connection); + r.websocket=&websocket; // process the request - r.core(config_filespec, strcasecmp(request_info.method, "HEAD")==0, main_method_name, &httpd_class_name); + r.core(config_filespec, main_method_name, &httpd_class_name); } catch(const Exception& e) { // exception in connection handling SAPI::log(info, "%s", e.comment()); const char* status = info.exception_http_status(e.type()); @@ -462,7 +465,7 @@ static void real_parser_handler(bool cgi const char* request_method=getenv("REQUEST_METHOD"); if(!filespec_to_process){ - SAPI::send_error(*sapi_info, "Parser/" PARSER_VERSION); + SAPI::send_error(*sapi_info, "Parser/" PARSER_VERSION_WITH_FEATURES); exit(1); } @@ -533,14 +536,15 @@ static void real_parser_handler(bool cgi pa_log("request_info: method=%s, uri=%s, q=%s, dr=%s, pt=%s", request_info.method, request_info.uri, request_info.query_string, request_info.document_root, request_info.path_translated); #endif - // prepare to process request - Request r(*sapi_info, request_info, cgi ? String::Language(String::L_HTML|String::L_OPTIMIZE_BIT) : String::L_AS_IS); { + // prepare to process request + Request r(*sapi_info, request_info, cgi ? String::Language(String::L_HTML|String::L_OPTIMIZE_BIT) : String::L_AS_IS); // initing ::request ptr for signal handlers RequestController rc(&r); // process the request - r.core(locate_config(config_filespec, parser3_filespec), strcasecmp(request_info.method, "HEAD")==0); + r.core(locate_config(config_filespec, parser3_filespec)); // clearing ::request in RequestController destructor to prevent signal handlers from accessing invalid memory + // then the request is destroyed, before the libraries are unloaded: its pool cleanups call them (memcached) } // finalize libraries @@ -602,7 +606,7 @@ static void usage(const char* message=NU " -l log_file Use this log file (/path/to/parser3.log)\n" " -p [host:]port Start web server on this port\n" " -h Display usage information (this message)\n", - PARSER_VERSION, + PARSER_VERSION_WITH_FEATURES, parser3_filespec ? parser3_filespec : "parser3" ); exit(EINVAL); }