--- parser3/src/include/pa_request.h 2026/09/25 12:55:42 1.274 +++ parser3/src/include/pa_request.h 2026/10/16 13:55:16 1.288 @@ -8,13 +8,15 @@ #ifndef PA_REQUEST_H #define PA_REQUEST_H -#define IDENT_PA_REQUEST_H "$Id: pa_request.h,v 1.274 2026/09/25 12:55:42 moko Exp $" +#define IDENT_PA_REQUEST_H "$Id: pa_request.h,v 1.288 2026/10/16 13:55:16 moko Exp $" #include "pa_pool.h" #include "pa_hash.h" +#include "pa_file.h" #include "pa_wcontext.h" #include "pa_value.h" #include "pa_vhash.h" +#include "pa_vresponse.h" #include "pa_stack.h" #include "pa_request_info.h" #include "pa_request_charsets.h" @@ -36,15 +38,14 @@ const size_t pseudo_file_no__process=1; // forwards -class Temp_lang; class Methoded; class VMethodFrame; class VMail; class VForm; -class VResponse; class VCookie; class VStateless_class; class VConsole; +class WebSocket; class VException; extern int pa_loop_limit; @@ -53,9 +54,10 @@ extern int pa_execute_recursion_limit; extern int pa_httpd_timeout; extern size_t pa_file_size_limit; +class Code_cache; + /// Main workhorse. class Request: public PA_Object { - friend class Temp_lang; friend class Temp_connection; friend class Temp_request_self; friend class Temp_value_element; @@ -63,6 +65,7 @@ class Request: public PA_Object { friend class Request_context_saver; friend class Exception_trace; friend class VException; + friend class Code_cache_manager; public: class Trace { @@ -128,7 +131,10 @@ private: return fsize==fbottom; } - Table &table(Request &r, const String* problem_source); + Table &table(Request &r, const String* problem_source) { + return table(r, problem_source, bottom_index(), top_index()); + } + Table &table(Request &r, const String* problem_source, size_t bottom, size_t top); }; ///@{ core data @@ -144,6 +150,8 @@ private: /// endless execute(execute(... preventing counter int anti_endless_execute_recursion; + int execute_recursion_limit; + void recursion_limit_reached(); ///@} @@ -161,8 +169,6 @@ public: VMethodFrame* method_frame; Value* rcontext; WContext* wcontext; - /// current language - String::Language flang; /// current connection SQL_Connection* fconnection; //@} @@ -205,7 +211,13 @@ public: core request processing BEWARE: may throw exception to you: catch it! */ - void core(const char* config_filespec, bool header_only, const String& amain_method_name = main_method_name, const String* amain_class_name = NULL); + void core(const char* config_filespec, const String& amain_method_name = main_method_name, const String* amain_class_name = NULL); + + /// ^response:stream[part]: the headers go with the first part + void stream(Value& part); + + /// sends headers and sets response.started + void start(VResponse::Started mode); /// executes ops void execute(ArrayOperation& ops); // execute.C @@ -240,14 +252,18 @@ public: /// execute ops with anti-recursion check void recursion_checked_execute(ArrayOperation& ops) { - if(++anti_endless_execute_recursion>=pa_execute_recursion_limit) { - anti_endless_execute_recursion=0; // give @exception a chance - throw Exception(PARSER_RUNTIME, 0, "call canceled - endless recursion detected"); - } + if(++anti_endless_execute_recursion>=execute_recursion_limit) + recursion_limit_reached(); execute(ops); // execute it anti_endless_execute_recursion--; } + /// take the recovery reserve back if recursion limit is far enough + void recursion_limit_try_restore() { + if(execute_recursion_limit>pa_execute_recursion_limit && anti_endless_execute_recursion classes_conf; @@ -386,7 +407,7 @@ private: private: // compile.C - ArrayClass& compile(VStateless_class* aclass, const char* source, const String* main_alias, uint file_no, int line_no_offset); + ArrayClass& compile(VStateless_class* aclass, const char* source, const String* main_alias, uint file_no, int line_no_offset, Code_cache* code); private: // execute.C @@ -395,10 +416,6 @@ private: // execute.C Value& get_element4call(Value& ncontext, const String& name); #endif -private: // defaults - - const String::Language fdefault_lang; - private: // mime types /// $MAIN:MIME-TYPES @@ -425,6 +442,7 @@ class VException: public VHashReference Exception fexception; String::Body ffile; Value* fhandled; + size_t ftrace_bottom, ftrace_top; public: Operation::Origin origin; const String* problem_source; @@ -436,6 +454,8 @@ public: override const VJunction* put_element(const String& name, Value* value); Value* handled(); + Table& stack(Request& r); + void expire_trace() { ftrace_top=size_t(-1); } }; /// Auto-object used to save request context across ^try body @@ -444,13 +464,11 @@ class Request_context_saver { /// execution stack size_t stack; - uint anti_endless_execute_recursion; + int anti_endless_execute_recursion; /// contexts VMethodFrame* method_frame; Value* rcontext; WContext* wcontext; - /// current language - String::Language flang; /// current connection SQL_Connection* fconnection; @@ -462,13 +480,11 @@ public: method_frame(ar.method_frame), rcontext(ar.rcontext), wcontext(ar.wcontext), - flang(ar.flang), fconnection(ar.fconnection) {} void restore() { fr.stack.set_top_index(stack); fr.anti_endless_execute_recursion=anti_endless_execute_recursion; fr.method_frame=method_frame, fr.rcontext=rcontext; fr.wcontext=wcontext; - fr.flang=flang; fr.fconnection=fconnection; } };