--- parser3/src/main/pa_globals.C 2019/12/25 22:22:06 1.205 +++ parser3/src/main/pa_globals.C 2021/01/16 15:47:05 1.212 @@ -1,7 +1,7 @@ /** @file Parser: globals. - Copyright (c) 2001-2017 Art. Lebedev Studio (http://www.artlebedev.com) + Copyright (c) 2001-2020 Art. Lebedev Studio (http://www.artlebedev.com) Author: Alexandr Petrosian (http://paf.design.ru) */ @@ -19,7 +19,6 @@ extern "C" { #include "pa_globals.h" #include "pa_socks.h" #include "pa_sapi.h" -#include "pa_threads.h" #include "pa_xml_io.h" #include "pa_common.h" #include "pa_symbols.h" @@ -29,7 +28,7 @@ extern "C" { #include "ltdl.h" #include "pcre.h" -volatile const char * IDENT_PA_GLOBALS_C="$Id: pa_globals.C,v 1.205 2019/12/25 22:22:06 moko Exp $" IDENT_PA_GLOBALS_H IDENT_PA_SAPI_H; +volatile const char * IDENT_PA_GLOBALS_C="$Id: pa_globals.C,v 1.212 2021/01/16 15:47:05 moko Exp $" IDENT_PA_GLOBALS_H IDENT_PA_SAPI_H; // defines @@ -47,13 +46,16 @@ short hex_value[0x100] = { 0, 10, 11, 12, 13, 14, 15, 0, 0, 0, 0, 0, 0, 0, 0, 0, }; -THREAD_LOCAL Request* thread_request=NULL; +THREAD_LOCAL Request* thread_request=NULL; // every TLS should be referenced elsewhere, or GC will collect it void pa_register_thread_request(Request& r) { thread_request=&r; } + /// retrives request set by pa_set_request function, useful in contextless places [slow] Request& pa_thread_request() { + if(!thread_request) + throw Exception(0, 0, "request is not initialized"); return *thread_request; } @@ -218,11 +220,11 @@ static void gc_substitute_memory_managem void pa_globals_init() { #ifndef PA_DEBUG_DISABLE_GC - GC_java_finalization=0; - // Dont collect unless explicitly requested - // this is quicker (~30% ), but less memory-efficient(~8%) - // so deciding for speed - GC_dont_gc=1; + // Dont collect unless explicitly requested. This is quicker (~30% ), + // but less memory-efficient(~8%), so deciding for speed. + GC_disable(); + // as we log allocation errors, we don't need default gc warnings (without timestamp and URI) + GC_set_warn_proc(GC_ignore_warn_proc); #endif // init socks @@ -354,7 +356,6 @@ void pa_dlinit() { // defines for VS2015 to link with gc/xml libs compiled in the previous VS versions #if _MSC_VER >= 1900 #pragma comment(lib,"legacy_stdio_definitions.lib") -extern "C" { FILE _iob[3] = { *stdin, *stdout, *stderr }; } #endif #endif // _MSC_VER