--- http/processor.c Fri Sep 6 20:13:37 2002 +++ 3.0/http/processor.c Mon Oct 7 18:14:31 2002 @@ -52,8 +52,6 @@ #define HEADER 3 #define PARAM 4 -/* Private variables */ -static sigjmp_buf timeout; /* Private prototypes */ static void do_service(RequestWrapper); @@ -73,8 +71,7 @@ static void destroy_entry(void *); static void internal_error(int, int, char *); static HttpParameter parse_parameters(char *); -static int do_timeout(int); -static void request_timeout(int); +static int is_available(int); /** @@ -103,7 +100,7 @@ * * @author Jan-Henrik Haukeland, * - * @version \$Id: processor.c,v 1.7 2002/09/06 18:13:37 hauk Exp $ + * @version \$Id: processor.c,v 1.9 2002/10/07 16:14:31 hauk Exp $ * * @file */ @@ -122,13 +119,17 @@ RequestWrapper W= wrapper; - if (do_timeout(W->socket)) - goto shutdown; + if(! is_available(W->socket)) { + + internal_error(W->socket, SC_REQUEST_TIMEOUT, + "Time out when handling the Request"); + goto shutdown; + + } do_service(W); shutdown: - alarm(0); destroy_wrapper(W); return NULL; @@ -965,30 +966,6 @@ /** - * Activate a timeout alarm clock, set a signal handler to handle the - * alarm and a jmp_buffer for handling a timeout. - */ -static int do_timeout(int client) { - - set_alarm_handler(request_timeout); - - alarm(REQUEST_TIMEOUT); - - if ( sigsetjmp(timeout, TRUE) ) { - - internal_error(client, SC_REQUEST_TIMEOUT, - "Time out when handling the Request"); - - return TRUE; - - } - - return FALSE; - -} - - -/** * Do Basic Authentication if this auth. style is allowed. */ static int is_authenticated(HttpRequest req, HttpResponse res) { @@ -1117,11 +1094,25 @@ /** - * Signal handler for a request timeout + * Check if data is available, if not, wait timeout seconds for data + * to be present. + * @param s A client socket + * @return TRUE if data is available otherwise FALSE */ -static void request_timeout(int sig) { +static int is_available(int s) { - siglongjmp(timeout, TRUE); + fd_set rset; + struct timeval tv; + + if(s < 0) + return FALSE; -} + FD_ZERO(&rset); + FD_SET(s, &rset); + tv.tv_sec= REQUEST_TIMEOUT; + tv.tv_usec= 0; + return (select(s+1, &rset, NULL, NULL, &tv)>0); + +} +