--- parser3/src/main/pa_request.C 2017/01/13 13:50:28 1.370 +++ parser3/src/main/pa_request.C 2017/05/03 17:53:19 1.375 @@ -1,12 +1,13 @@ /** @file Parser: request class main part. @see compile.C and execute.C. - Copyright (c) 2001-2015 Art. Lebedev Studio (http://www.artlebedev.com) + Copyright (c) 2001-2017 Art. Lebedev Studio (http://www.artlebedev.com) Author: Alexandr Petrosian (http://paf.design.ru) */ #include "pa_sapi.h" #include "pa_common.h" +#include "pa_os.h" #include "pa_request.h" #include "pa_wwrapper.h" #include "pa_vclass.h" @@ -32,7 +33,7 @@ #include "pa_vconsole.h" #include "pa_vdate.h" -volatile const char * IDENT_PA_REQUEST_C="$Id: pa_request.C,v 1.370 2017/01/13 13:50:28 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.375 2017/05/03 17:53:19 moko Exp $" IDENT_PA_REQUEST_H IDENT_PA_REQUEST_CHARSETS_H IDENT_PA_REQUEST_INFO_H IDENT_PA_VCONSOLE_H; // consts @@ -89,6 +90,7 @@ size_t pa_file_size_limit=FILE_SIZE_LIMI #define LOOP_LIMIT_NAME "max_loop" #define RECOURSION_LIMIT_NAME "max_recoursion" #define FILE_SIZE_LIMIT_NAME "max_file_size" +#define LOCK_WAIT_TIMEOUT_NAME "lock_wait_timeout" #define CONF_METHOD_NAME "conf" #define POST_PROCESS_METHOD_NAME "postprocess" #define CLASS_PATH_NAME "CLASS_PATH" @@ -108,6 +110,7 @@ static const String limits_name(LIMITS_N static const String loop_limit_name(LOOP_LIMIT_NAME); static const String recoursion_limit_name(RECOURSION_LIMIT_NAME); static const String file_size_limit_name(FILE_SIZE_LIMIT_NAME); +static const String lock_wait_timeout_name(LOCK_WAIT_TIMEOUT_NAME); static const String conf_method_name(CONF_METHOD_NAME); static const String post_process_method_name(POST_PROCESS_METHOD_NAME); @@ -145,8 +148,8 @@ Request::Request(SAPI_Info& asapi_info, wcontext(0), flang(adefault_lang), fconnection(0), - fskip(SKIP_NOTHING), fin_cycle(0), + fskip(SKIP_NOTHING), // public request_info(arequest_info), @@ -226,7 +229,7 @@ Value& Request::get_self() { return meth VStateless_class* Request::get_class(const String& name){ VStateless_class* result=classes().get(name); if(!result) - if(const Method *method=main_class.get_method(autouse_method_name)){ + if(const Method *method=main_class.get_element_method(autouse_method_name)){ Value *vname=new VString(name); CONSTRUCTOR_FRAME_ACTION(*method, 0 /*no parent*/, main_class, { frame.store_params(&vname, 1); @@ -319,6 +322,18 @@ void Request::configure_admin(VStateless throw Exception(PARSER_RUNTIME, 0, "$" MAIN_CLASS_NAME ":LIMITS." FILE_SIZE_LIMIT_NAME " must be number"); } + pa_lock_attempts=PA_LOCK_ATTEMPTS; + if(limits) + if(Value* lock_wait_timeout=limits->get_element(lock_wait_timeout_name)) { + if(lock_wait_timeout->is_evaluated_expr()) { + double limit=lock_wait_timeout->as_double(); + if(limit >= 3600*24) + throw Exception(PARSER_RUNTIME, 0, "$" MAIN_CLASS_NAME ":LIMITS." LOCK_WAIT_TIMEOUT_NAME " must be less then %d", 3600*24); + pa_lock_attempts=(unsigned int)(limit*2)+1; + } else + throw Exception(PARSER_RUNTIME, 0, "$" MAIN_CLASS_NAME ":LIMITS." LOCK_WAIT_TIMEOUT_NAME " must be number"); + } + // configure method_frame options // until someone with less privileges have overriden them methoded_array().configure_admin(*this); @@ -619,7 +634,7 @@ void Request::use_file(const String& fil static String use("USE"); try { static VHash* voptions=new VHash(); - if(const Method *method=main_class.get_method(use_method_name)){ + if(const Method *method=main_class.get_element_method(use_method_name)){ Value *params[]={new VString(file_name), voptions}; voptions->hash().put(origin_key, new VString(*use_filespec));