--- parser3/src/main/pa_request.C 2026/10/23 20:48:48 1.469 +++ parser3/src/main/pa_request.C 2026/11/21 23:38:25 1.475 @@ -37,7 +37,7 @@ #include "pa_varray.h" #include "pa_code_cache.h" -volatile const char * IDENT_PA_REQUEST_C="$Id: pa_request.C,v 1.469 2026/10/23 20:48:48 moko Exp $" IDENT_PA_REQUEST_H IDENT_PA_REQUEST_CHARSETS_H IDENT_PA_REQUEST_INFO_H IDENT_PA_VCONSOLE_H; +volatile const char * IDENT_PA_REQUEST_C="$Id: pa_request.C,v 1.475 2026/11/21 23:38:25 moko Exp $" IDENT_PA_REQUEST_H IDENT_PA_REQUEST_CHARSETS_H IDENT_PA_REQUEST_INFO_H IDENT_PA_VCONSOLE_H; // consts @@ -116,6 +116,7 @@ static const String lock_wait_timeout_na static const String httpd_name("HTTPD"); static const String httpd_timeout_name("timeout"); static const String httpd_mode_name("mode"); +static const String httpd_max_connections_name("max-connections"); #ifdef CODE_CACHE static const String httpd_code_cache_name("code-cache"); #endif @@ -154,6 +155,12 @@ void Request::recursion_limit_reached() throw Exception(PARSER_RUNTIME, 0, "call canceled - endless recursion detected"); } +void Request::throw_interrupted() { + finterrupted=0; + set_skip(SKIP_NOTHING); + throw Interrupted_exception(response.timeout); +} + Request::Request(SAPI_Info& asapi_info, Request_info& arequest_info, String::Language adefault_lang): // private anti_endless_execute_recursion(0), @@ -167,6 +174,7 @@ Request::Request(SAPI_Info& asapi_info, fconnection(0), fin_cycle(0), fskip(SKIP_NOTHING), + finterrupted(0), // public request_info(arequest_info), @@ -187,8 +195,6 @@ Request::Request(SAPI_Info& asapi_info, // private mime types mime_types(0) { - pa_register_thread_request(*this); - // file_no=0 => unknown file_list+=String::Body("UNKNOWN"); file_list+=String::Body("-body of process-"); // pseudo_file_no__process @@ -231,9 +237,14 @@ Request::Request(SAPI_Info& asapi_info, put_class(new VMath); // memory class put_class(new VMemory); + + // the last: the destructor is not called if the constructor throws + thread_request=this; } Request::~Request() { + thread_request=0; + #ifdef XML // if for some strange reason xml generic errors failed to be reported, free them up if(const char* xml_generic_errors=xmlGenericErrors()) { @@ -339,12 +350,6 @@ void Request::configure_admin(VStateless VClass::getter_protected=getter_protected; // thread local: changes in Temp_getter_protected #endif -#ifdef CODE_CACHE - CONF_OPTION(httpd, httpd_code_cache_name, { - Code_cache_manager::set_enabled(option->as_bool()); - }, "HTTPD.%s must be bool"); -#endif - bool all_vars_local=false; CONF_OPTION(conf, locals_name, { all_vars_local=option->as_bool(); @@ -403,12 +408,18 @@ void Request::configure_admin(VStateless double limit=option->as_double(); if(limit >= 3600*24) throw Exception(PARSER_RUNTIME, 0, "$MAIN:LIMITS.%s must be less than %d", lock_wait_timeout_name.cstr(), 3600*24); - lock_attempts=(unsigned int)(limit*2)+1; + lock_attempts=PA_LOCK_TIME_TO_ATTEMPTS(limit); }, "LIMITS.%s must be number"); pa_lock_attempts=lock_attempts; Value* httpd=conf_class.get_element(httpd_name); +#ifdef CODE_CACHE + CONF_OPTION(httpd, httpd_code_cache_name, { + Code_cache_manager::set_enabled(option->as_bool()); + }, "HTTPD.%s must be bool"); +#endif + int httpd_timeout=HTTPD_TIMEOUT; CONF_OPTION(httpd, httpd_timeout_name, { httpd_timeout=option->as_int(); @@ -416,8 +427,15 @@ void Request::configure_admin(VStateless }, "HTTPD.%s must be int"); pa_httpd_timeout=httpd_timeout; + int httpd_max_connections=INT_MAX; + CONF_OPTION(httpd, httpd_max_connections_name, { + httpd_max_connections=option->as_int(); + if(httpd_max_connections<=0) httpd_max_connections=INT_MAX; + }, "HTTPD.%s must be int"); + HTTPD_Server::max_connections=httpd_max_connections; + if(httpd) - if(Value* option=httpd->get_element( httpd_mode_name)) { + if(Value* option=httpd->get_element(httpd_mode_name)) { if(option->get_junction()) throw Exception(PARSER_RUNTIME, 0, "$MAIN:HTTPD:mode must be string"); HTTPD_Server::set_mode(option->as_string());