--- parser3/src/main/pa_common.C 2004/12/10 07:34:05 1.197 +++ parser3/src/main/pa_common.C 2004/12/10 07:55:22 1.199 @@ -5,7 +5,7 @@ Author: Alexandr Petrosian (http://paf.design.ru) */ -static const char * const IDENT_COMMON_C="$Date: 2004/12/10 07:34:05 $"; +static const char * const IDENT_COMMON_C="$Date: 2004/12/10 07:55:22 $"; #include "pa_common.h" #include "pa_exception.h" @@ -207,7 +207,7 @@ static int http_read_response(char*& res #ifdef PA_USE_ALARM static sigjmp_buf timeout_env; -static void timeout_handler(int sig){ +static void timeout_handler(int /*sig*/){ siglongjmp(timeout_env, 1); } #endif @@ -222,19 +222,19 @@ static int http_request(char*& response, 0, "zero hostname"); //never + volatile int sock=-1; #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] + // rewritten simplier [athough duplicating closesocket code] if(sock>=0) closesocket(sock); throw Exception("http.timeout", - origin_string, + 0, "timeout occured while retrieving document"); return 0; // never } else { @@ -266,9 +266,13 @@ static int http_request(char*& response, setsockopt(sock, SOL_SOCKET, SO_LINGER, (const char *)&dont_linger, sizeof(dont_linger)); #endif -#ifndef PA_USE_ALARM +#if defined(SO_SNDTIMEO) || defined(SO_RCVTIMEO) int timeout_ms=timeout_secs*1000; +#endif +#ifdef SO_SNDTIMEO setsockopt(sock, SOL_SOCKET, SO_SNDTIMEO, (const char*)&timeout_ms, sizeof(timeout_ms)); +#endif +#ifdef SO_RCVTIMEO setsockopt(sock, SOL_SOCKET, SO_RCVTIMEO, (const char*)&timeout_ms, sizeof(timeout_ms)); #endif