httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ben Laurie <...@gonzo.ben.algroup.co.uk>
Subject Keepalive timeout patch
Date Sat, 14 Dec 1996 21:33:05 GMT
I'm afraid this has got a little tangled with an OS patch I posted before. I
don't think there was any opposition, so I'm taking the liberty of leaving it
bundled.

Cheers,

Ben.

Index: conf.h
===================================================================
RCS file: /export/home/cvs/apache/src/conf.h,v
retrieving revision 1.59
diff -c -r1.59 conf.h
*** conf.h	1996/12/12 16:45:32	1.59
--- conf.h	1996/12/14 21:06:13
***************
*** 94,100 ****
  #define HAVE_SHMGET
  #define HAVE_CRYPT_H
  #define NO_LONG_DOUBLE
- #define BROKEN_WAIT
  
  #elif defined(HPUX) || defined(HPUX10)
  #define HAVE_SYS_RESOURCE_H
--- 94,99 ----
Index: http_main.c
===================================================================
RCS file: /export/home/cvs/apache/src/http_main.c,v
retrieving revision 1.95
diff -c -r1.95 http_main.c
*** http_main.c	1996/12/10 01:11:58	1.95
--- http_main.c	1996/12/14 21:06:20
***************
*** 453,459 ****
      }
  }
  
! void hard_timeout (char *name, request_rec *r)
  {
      timeout_req = r;
      timeout_name = name;
--- 453,459 ----
      }
  }
  
! void keepalive_timeout (char *name, request_rec *r)
  {
      timeout_req = r;
      timeout_name = name;
***************
*** 465,470 ****
--- 465,479 ----
         alarm (r->server->timeout);
  }
  
+ void hard_timeout (char *name, request_rec *r)
+ {
+     timeout_req = r;
+     timeout_name = name;
+     
+     signal(SIGALRM,(void (*)())timeout);
+     alarm (r->server->timeout);
+ }
+ 
  void soft_timeout (char *name, request_rec *r)
  {
      timeout_name = name;
***************
*** 941,962 ****
      }
  }
  
! #ifdef BROKEN_WAIT
  /*
  Some systems appear to fail to deliver dead children to wait() at times.
! This sorts them out.
  */
! void reap_children()
      {
      int status,n;
  
      for(n=0 ; n < HARD_SERVER_LIMIT ; ++n)
  	if(scoreboard_image->servers[n].status != SERVER_DEAD
  	   && waitpid(scoreboard_image->servers[n].pid,&status,WNOHANG) == -1
  	   && errno == ECHILD)
  	    {
  	    update_child_status(n,SERVER_DEAD,NULL);
  	    }
      }
  #endif
  
--- 950,977 ----
      }
  }
  
! #if defined(BROKEN_WAIT) || defined(NEED_WAITPID)
  /*
  Some systems appear to fail to deliver dead children to wait() at times.
! This sorts them out. In fact, this may have been caused by a race condition
! in wait_or_timeout(). But this routine is still useful for systems with no
! waitpid().
  */
! int reap_children()
      {
      int status,n;
+     int ret=0;
  
      for(n=0 ; n < HARD_SERVER_LIMIT ; ++n)
  	if(scoreboard_image->servers[n].status != SERVER_DEAD
  	   && waitpid(scoreboard_image->servers[n].pid,&status,WNOHANG) == -1
  	   && errno == ECHILD)
  	    {
+ 	    sync_scoreboard_image();
  	    update_child_status(n,SERVER_DEAD,NULL);
+ 	    ret=1;
  	    }
+     return ret;
      }
  #endif
  
***************
*** 968,973 ****
--- 983,989 ----
  
  static int wait_or_timeout(int *status)
      {
+ #ifndef NEED_WAITPID
      int ret;
  
      ret=waitpid(-1,status,WNOHANG);
***************
*** 977,982 ****
--- 993,1003 ----
  	return -1;
  	}
      return ret;
+ #else
+     if(!reap_children())
+ 	sleep(1);
+     return -1;
+ #endif
      }
  
  #else
Index: http_main.h
===================================================================
RCS file: /export/home/cvs/apache/src/http_main.h,v
retrieving revision 1.6
diff -c -r1.6 http_main.h
*** http_main.h	1996/12/01 20:28:28	1.6
--- http_main.h	1996/12/14 21:06:21
***************
*** 86,91 ****
--- 86,92 ----
   */
  
  void hard_timeout (char *, request_rec *);
+ void keepalive_timeout (char *, request_rec *);
  void soft_timeout (char *, request_rec *);
  void kill_timeout (request_rec *);     
  void reset_timeout (request_rec *);
Index: http_protocol.c
===================================================================
RCS file: /export/home/cvs/apache/src/http_protocol.c,v
retrieving revision 1.82
diff -c -r1.82 http_protocol.c
*** http_protocol.c	1996/12/12 00:27:59	1.82
--- http_protocol.c	1996/12/14 21:06:28
***************
*** 652,658 ****
  
      /* Get the request... */
      
!     hard_timeout ("read", r);
      if (!read_request_line (r)) return NULL;
      if (!r->assbackwards) get_mime_headers (r);
  
--- 652,658 ----
  
      /* Get the request... */
      
!     keepalive_timeout ("read", r);
      if (!read_request_line (r)) return NULL;
      if (!r->assbackwards) get_mime_headers (r);
  

-- 
Ben Laurie                Phone: +44 (181) 994 6435  Email: ben@algroup.co.uk
Freelance Consultant and  Fax:   +44 (181) 994 6472
Technical Director        URL: http://www.algroup.co.uk/Apache-SSL
A.L. Digital Ltd,         Apache Group member (http://www.apache.org)
London, England.          Apache-SSL author

Mime
View raw message