--- parser3/src/main/pa_common.C 2003/01/16 09:07:20 1.142 +++ parser3/src/main/pa_common.C 2003/02/24 12:26:48 1.145 @@ -1,11 +1,11 @@ /** @file Parser: commonly functions. - Copyright(c) 2001, 2002 ArtLebedev Group (http://www.artlebedev.com) + Copyright(c) 2001, 2003 ArtLebedev Group (http://www.artlebedev.com) Author: Alexandr Petrosian (http://paf.design.ru) */ -static const char* IDENT_COMMON_C="$Date: 2003/01/16 09:07:20 $"; +static const char* IDENT_COMMON_C="$Date: 2003/02/24 12:26:48 $"; #include "pa_common.h" #include "pa_exception.h" @@ -171,10 +171,10 @@ static int http_read_response(String& re /* ********************** request *************************** */ #if defined(SIGALRM) && defined(HAVE_SIGSETJMP) && defined(HAVE_SIGLONGJMP) -# define WE_CAN_USE_ALARM +# define PA_USE_ALARM #endif -#ifdef WE_CAN_USE_ALARM +#ifdef PA_USE_ALARM static sigjmp_buf timeout_env; static void timeout_handler(int sig){ siglongjmp(timeout_env, 1); @@ -192,20 +192,25 @@ static int http_request(String& response origin_string, "zero hostname"); //never -#ifdef WE_CAN_USE_ALARM +#ifdef PA_USE_ALARM signal(SIGALRM, timeout_handler); #endif int sock=-1; +#ifdef PA_USE_ALARM + if(sigsetjmp(timeout_env, 1)) { + // stupid gcc [2.95.4] generated bad code + // which failed to handle sigsetjmp+throw: crashed inside of pre-throw code. + // rewritten simplier [though duplicating closesocket code] + if(sock>=0) + closesocket(sock); + throw Exception("http.timeout", + origin_string, + "timeout occured while retrieving document"); + } else { + alarm(timeout); +#endif try { int result; -#ifdef WE_CAN_USE_ALARM - if(sigsetjmp(timeout_env, 1)) - throw Exception("http.timeout", - origin_string, - "timeout occured while retrieving document"); - else { - alarm(timeout); -#endif struct sockaddr_in dest; if(!set_addr(&dest, host, port)) @@ -229,7 +234,7 @@ static int http_request(String& response result=http_read_response(response, sock, fail_on_status_ne_200); closesocket(sock); -#ifdef WE_CAN_USE_ALARM +#ifdef PA_USE_ALARM alarm(0); } #endif @@ -237,7 +242,7 @@ static int http_request(String& response } catch(...) { if(sock>=0) closesocket(sock); -#ifdef WE_CAN_USE_ALARM +#ifdef PA_USE_ALARM alarm(0); #endif /*re*/throw; @@ -273,7 +278,7 @@ static void file_read_http(Pool& pool, c bool fail_on_status_ne_200=true; Value *vheaders=0; - String connect_string(pool); + String& connect_string=*new(pool) String(pool); // must not be local [exception may be reported outside] // not in ^sql{... UL_SQL ...} spirit, but closer to ^file::load one connect_string.append(file_spec, String::UL_URI); // tainted pieces -> URI pieces