/[monit]/monit/http/processor.c
ViewVC logotype

Diff of /monit/http/processor.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.8 by hauk, Mon Oct 7 14:30:09 2002 UTC revision 1.9 by hauk, Mon Oct 7 16:14:31 2002 UTC
# Line 52  Line 52 
52  #define HEADER    3  #define HEADER    3
53  #define PARAM     4  #define PARAM     4
54    
 /* Private variables */  
 static sigjmp_buf timeout;  
55    
56  /* Private prototypes */  /* Private prototypes */
57  static void do_service(RequestWrapper);  static void do_service(RequestWrapper);
# Line 73  static void destroy_HttpResponse(HttpRes Line 71  static void destroy_HttpResponse(HttpRes
71  static void destroy_entry(void *);  static void destroy_entry(void *);
72  static void internal_error(int, int, char *);  static void internal_error(int, int, char *);
73  static HttpParameter parse_parameters(char *);  static HttpParameter parse_parameters(char *);
74  static void request_timeout(int);  static int is_available(int);
75    
76    
77  /**  /**
# Line 121  void *http_processor(void *wrapper) { Line 119  void *http_processor(void *wrapper) {
119        
120    RequestWrapper W= wrapper;    RequestWrapper W= wrapper;
121    
122    set_alarm_handler(request_timeout);    if(! is_available(W->socket)) {
   alarm(REQUEST_TIMEOUT);  
   
   if(sigsetjmp(timeout, TRUE) ) {  
123            
124      internal_error(W->socket, SC_REQUEST_TIMEOUT,      internal_error(W->socket, SC_REQUEST_TIMEOUT,
125                     "Time out when handling the Request");                     "Time out when handling the Request");
# Line 135  void *http_processor(void *wrapper) { Line 130  void *http_processor(void *wrapper) {
130    do_service(W);    do_service(W);
131    
132    shutdown:    shutdown:
   alarm(0);  
133    destroy_wrapper(W);    destroy_wrapper(W);
134    
135    return NULL;    return NULL;
# Line 1100  static HttpParameter parse_parameters(ch Line 1094  static HttpParameter parse_parameters(ch
1094    
1095    
1096  /**  /**
1097   * Signal handler for a request timeout   * Check if data is available, if not, wait timeout seconds for data
1098     * to be present.
1099     * @param s A client socket
1100     * @return TRUE if data is available otherwise FALSE
1101   */   */
1102  static void request_timeout(int sig) {  static int is_available(int s) {
1103    
1104      fd_set rset;
1105      struct timeval tv;
1106    
1107    siglongjmp(timeout, TRUE);    if(s < 0)
1108          return FALSE;
1109        
1110  }    FD_ZERO(&rset);
1111      FD_SET(s, &rset);
1112      tv.tv_sec= REQUEST_TIMEOUT;
1113      tv.tv_usec= 0;
1114    
1115      return (select(s+1, &rset, NULL, NULL, &tv)>0);
1116    
1117    }
1118    

Legend:
Removed from v.1.8  
changed lines
  Added in v.1.9

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26