httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sameer <sam...@c2.net>
Subject [No Subject]
Date Sun, 03 Nov 1996 23:40:29 GMT
? Configuration
? modules.c
? Makefile
? httpsd
? mod_php.h
? mod_php.c
? php/config.log
? php/config.h
? php/config.cache
? php/config.status
? php/src/Makefile
? util/htpasswd
? util/htdigest
? util/rotatelogs
? util/logresolve
Index: alloc.c
===================================================================
RCS file: /usr/local/apache-cvs/stronghold/apache/alloc.c,v
retrieving revision 1.2
diff -c -r1.2 alloc.c
*** 1.2	1996/09/27 02:16:16
--- alloc.c	1996/11/03 23:44:09
***************
*** 59,66 ****
   * rst --- 4/95 --- 6/95
   */
  
! #include "conf.h"
! #include "alloc.h"
  
  #include <stdarg.h>
  
--- 59,65 ----
   * rst --- 4/95 --- 6/95
   */
  
! #include "httpd.h"
  
  #include <stdarg.h>
  
***************
*** 824,829 ****
--- 823,915 ----
    new->kill_how = how;
    new->next = a->subprocesses;
    a->subprocesses = new;
+ }
+ 
+ int spawn_child_buff (pool *p, void (*func)(void *), void *data,
+ 		      enum kill_conditions kill_how,
+ 		      BUFF **pipe_in, BUFF **pipe_out)
+ {
+   int pid;
+   int in_fds[2];
+   int out_fds[2];
+ 
+   block_alarms();
+   
+   if (pipe_in && pipe (in_fds) < 0)
+   {
+       unblock_alarms();
+       return 0;
+   }
+   
+   if (pipe_out && pipe (out_fds) < 0) {
+     if (pipe_in) {
+       close (in_fds[0]); close (in_fds[1]);
+     }
+     unblock_alarms();
+     return 0;
+   }
+ 
+   if ((pid = fork()) < 0) {
+     if (pipe_in) {
+       close (in_fds[0]); close (in_fds[1]);
+     }
+     if (pipe_out) {
+       close (out_fds[0]); close (out_fds[1]);
+     }
+     unblock_alarms();
+     return 0;
+   }
+ 
+   if (!pid) {
+     /* Child process */
+     
+     if (pipe_out) {
+       close (out_fds[0]);
+       dup2 (out_fds[1], STDOUT_FILENO);
+       close (out_fds[1]);
+     }
+ 
+     if (pipe_in) {
+       close (in_fds[1]);
+       dup2 (in_fds[0], STDIN_FILENO);
+       close (in_fds[0]);
+     }
+ 
+     /* HP-UX SIGCHLD fix goes here, if someone will remind me what it is... */
+     signal (SIGCHLD, SIG_DFL);	/* Was that it? */
+     
+     func (data);
+     exit (0);			/* Should never get here... */
+   }
+ 
+   /* Parent process */
+ 
+   note_subprocess (p, pid, kill_how);
+   
+   if (pipe_out) {
+     close (out_fds[1]);
+ #ifdef __EMX__
+     /* Need binary mode set for OS/2. */
+     *pipe_out = fdopen (out_fds[0], "rb");
+ #else
+     *pipe_out = bcreate(p, B_RD);
+     bpushfd(*pipe_out, out_fds[0], out_fds[0]);
+ #endif  
+   }
+ 
+   if (pipe_in) {
+     close (in_fds[0]);
+ #ifdef __EMX__
+     /* Need binary mode set for OS/2 */
+     *pipe_in = fdopen (in_fds[1], "wb");
+ #else
+     *pipe_in = bcreate(p, B_WR);
+     bpushfd(*pipe_in, in_fds[1], in_fds[1]);
+ #endif
+   }
+ 
+   unblock_alarms();
+   return pid;
  }
  
  int spawn_child (pool *p, void (*func)(void *), void *data,
Index: buff.c
===================================================================
RCS file: /usr/local/apache-cvs/stronghold/apache/buff.c,v
retrieving revision 1.4
diff -c -r1.4 buff.c
*** 1.4	1996/10/31 02:49:05
--- buff.c	1996/11/03 23:44:09
***************
*** 112,118 ****
      else fb->inbase = NULL;
  
      if (flags & B_WR) fb->outbase = palloc(p, fb->bufsiz);
!     else fb->inbase = NULL;
  
      fb->inptr = fb->inbase;
  
--- 112,118 ----
      else fb->inbase = NULL;
  
      if (flags & B_WR) fb->outbase = palloc(p, fb->bufsiz);
!     else fb->outbase = NULL;
  
      fb->inptr = fb->inbase;
  
Index: http_protocol.c
===================================================================
RCS file: /usr/local/apache-cvs/stronghold/apache/http_protocol.c,v
retrieving revision 1.7
diff -c -r1.7 http_protocol.c
*** 1.7	1996/09/28 06:15:07
--- http_protocol.c	1996/11/03 23:44:09
***************
*** 795,800 ****
--- 795,860 ----
      return total_bytes_sent;
  }
  
+ long send_fb(BUFF *fb, request_rec *r)
+ {
+     char buf[IOBUFSIZE];
+     long total_bytes_sent;
+     register int n,o,w;
+     conn_rec *c = r->connection;
+     
+     total_bytes_sent = 0;
+ 
+     /* Clear out the buffer */
+     if(fb->incnt != 0)
+       {
+ 	int o;
+ 
+ 	o = bwrite(c->client, fb->inptr, fb->incnt);
+ 	fb->incnt -= o;
+ 	fb->inptr += o;
+       }
+     /* make unbuffered */
+     fb->flags &= ~B_RD;
+ 	
+     /* and make non-blocking */
+     fcntl(fb->fd_in, F_SETFL, O_NONBLOCK);
+ 
+     while(1)
+       {
+ 	fd_set fds;
+ 
+ 	bflush(c->client);
+ 
+ 
+ 	FD_ZERO(&fds);
+ 	FD_SET(fb->fd_in, &fds);
+ 	select(FD_SETSIZE, &fds, NULL, NULL, NULL); 
+       
+         while ((n= bread(fb, buf, IOBUFSIZE)) < 1
+ 	       && fb->flags & B_ERROR && errno == EINTR)
+ 	    continue;
+ 
+ 	if (n < 1) {
+             break;
+         }
+         o=0;
+ 	total_bytes_sent += n;
+ 	
+         while(n && !r->connection->aborted) {
+             w=bwrite(c->client, &buf[o], n);
+ 	    if(w <= 0)
+ 		break;
+ 	    reset_timeout(r); /* reset timeout after successfule write */
+             n-=w;
+             o+=w;
+         }
+     }
+     bflush(c->client);
+     
+     SET_BYTES_SENT(r);
+     return total_bytes_sent;
+ }
+ 
  int rputc (int c, request_rec *r)
  {
      if (r->connection->aborted) return EOF;
Index: mod_cgi.c
===================================================================
RCS file: /usr/local/apache-cvs/stronghold/apache/mod_cgi.c,v
retrieving revision 1.2
diff -c -r1.2 mod_cgi.c
*** 1.2	1996/09/20 17:02:57
--- mod_cgi.c	1996/11/03 23:44:09
***************
*** 51,56 ****
--- 51,59 ----
   *
   */
  
+ /* Some defaults for now */
+ #define CGI_TIMEOUT 200 /* milliseconds */
+ #define CGI_BUFFER  8192 /* bytes */
  
  /*
   * http_script: keeps all script-related ramblings together.
***************
*** 208,214 ****
  {
      int nph;
      char *argv0;
!     FILE *script_out, *script_in;
      char argsbuffer[HUGE_STRING_LEN];
      int is_included = !strcmp (r->protocol, "INCLUDED");
      char *lenp = table_get (r->headers_in, "Content-length");
--- 211,217 ----
  {
      int nph;
      char *argv0;
!     BUFF *script_out, *script_in;
      char argsbuffer[HUGE_STRING_LEN];
      int is_included = !strcmp (r->protocol, "INCLUDED");
      char *lenp = table_get (r->headers_in, "Content-length");
***************
*** 267,287 ****
              return SERVER_ERROR;
          }
      } else {
!         if (!spawn_child (r->connection->pool, cgi_child, (void *)&cld,
! 			  (nph && !ApacheSSLCheck(r->server))
! 			  ? just_wait : kill_after_timeout,
! 			  &script_out, &script_in)) {
              log_reason ("couldn't spawn child process", r->filename, r);
              return SERVER_ERROR;
          }
      }
      
  #else
!      if (!spawn_child (r->connection->pool, cgi_child, (void *)&cld,
! 		       (nph && !ApacheSSLCheck(r->server))
! 		       ? just_wait : kill_after_timeout, 
! 		       &script_out, (nph && !ApacheSSLCheck(r->server))
! 		       ? NULL : &script_in)) {
          log_reason ("couldn't spawn child process", r->filename, r);
          return SERVER_ERROR;
      }
--- 270,290 ----
              return SERVER_ERROR;
          }
      } else {
!         if (!spawn_child_buff (r->connection->pool, cgi_child, (void *)&cld,
! 			       (nph && !ApacheSSLCheck(r->server))
! 			       ? just_wait : kill_after_timeout,
! 			       &script_out, &script_in)) {
              log_reason ("couldn't spawn child process", r->filename, r);
              return SERVER_ERROR;
          }
      }
      
  #else
!      if (!spawn_child_buff (r->connection->pool, cgi_child, (void *)&cld,
! 			    (nph && !ApacheSSLCheck(r->server))
! 			    ? just_wait : kill_after_timeout, 
! 			    &script_out, (nph && !ApacheSSLCheck(r->server))
! 			    ? NULL : &script_in)) {
          log_reason ("couldn't spawn child process", r->filename, r);
          return SERVER_ERROR;
      }
***************
*** 313,319 ****
  	    len_read = read_client_block (r, argsbuffer, len_to_read);
  	    if (len_read == 0)
  		break;
! 	    if (fwrite (argsbuffer, 1, len_read, script_out) == 0)
  		break;
  	    remaining -= len_read;
  	}
--- 316,322 ----
  	    len_read = read_client_block (r, argsbuffer, len_to_read);
  	    if (len_read == 0)
  		break;
! 	    if (bwrite (script_out, argsbuffer, len_read) == 0)
  		break;
  	    remaining -= len_read;
  	}
***************
*** 330,350 ****
  	    if (len_read == 0) break;
  	}
      
! 	fflush (script_out);
  	signal (SIGPIPE, handler);
  	
  	kill_timeout (r);
      }
  #endif    
      
!     pfclose (r->connection->pool, script_out);
      
      /* Handle script return... */
      if (script_in && !nph) {
          char *location;
  	int ret;
!       
!         if ((ret = scan_script_header(r, script_in)))
  	    return ret;
  	
  	location = table_get (r->headers_out, "Location");
--- 333,356 ----
  	    if (len_read == 0) break;
  	}
      
! 	bflush (script_out);
  	signal (SIGPIPE, handler);
  	
  	kill_timeout (r);
      }
  #endif    
      
!     bclose (script_out);
      
      /* Handle script return... */
      if (script_in && !nph) {
          char *location;
  	int ret;
! 
! 	/* Convert script_in to a BUFF */
! 	
! 
!         if ((ret = scan_script_header_buff(r, script_in)))
  	    return ret;
  	
  	location = table_get (r->headers_out, "Location");
***************
*** 353,359 ****
  	  
              /* Soak up all the script output */
  	    hard_timeout ("read from script", r);
! 	    while (fgets(argsbuffer, HUGE_STRING_LEN-1, script_in) != NULL)
  	        continue;
  	    kill_timeout (r);
  
--- 359,365 ----
  	  
              /* Soak up all the script output */
  	    hard_timeout ("read from script", r);
! 	    while (bgets(argsbuffer, HUGE_STRING_LEN-1, script_in) != NULL)
  	        continue;
  	    kill_timeout (r);
  
***************
*** 376,391 ****
  	
  	hard_timeout ("send script output", r);
  	send_http_header(r);
!         if(!r->header_only) send_fd (script_in, r);
  	kill_timeout (r);
! 	pfclose (r->connection->pool, script_in);
      }
      else if(nph && ApacheSSLCheck(r->server))
        {
  	hard_timeout ("send nph script output", r);
! 	send_fd(script_in, r);
  	kill_timeout (r);
! 	pfclose(r->connection->pool, script_in);
        }
  
  #ifdef __EMX__
--- 382,397 ----
  	
  	hard_timeout ("send script output", r);
  	send_http_header(r);
!         if(!r->header_only) send_fb (script_in, r);
  	kill_timeout (r);
! 	bclose (script_in);
      }
      else if(nph && ApacheSSLCheck(r->server))
        {
  	hard_timeout ("send nph script output", r);
! 	send_fb(script_in, r);
  	kill_timeout (r);
! 	bclose(script_in);
        }
  
  #ifdef __EMX__
Index: util_script.c
===================================================================
RCS file: /usr/local/apache-cvs/stronghold/apache/util_script.c,v
retrieving revision 1.1.1.1
diff -c -r1.1.1.1 util_script.c
*** 1.1.1.1	1996/07/30 01:43:25
--- util_script.c	1996/11/03 23:44:09
***************
*** 239,245 ****
      }
  }
  
! int scan_script_header(request_rec *r, FILE *f)
  {
      char w[MAX_STRING_LEN];
      char *l;
--- 239,246 ----
      }
  }
  
! int
! scan_script_header_buff(request_rec *r, BUFF *fb)
  {
      char w[MAX_STRING_LEN];
      char *l;
***************
*** 249,255 ****
      
      while(1) {
  
! 	if (fgets(w, MAX_STRING_LEN-1, f) == NULL) {
  	    log_reason ("Premature end of script headers", r->filename, r);
  	    return SERVER_ERROR;
          }
--- 250,335 ----
      
      while(1) {
  
!         if (bgets(w, MAX_STRING_LEN-1, fb) == NULL) {
! 	    log_reason ("Premature end of script headers", r->filename, r);
! 	    return SERVER_ERROR;
!         }
! 
! 	/* Delete terminal (CR?)LF */
! 	
! 	p = strlen(w);
! 	if (p > 0 && w[p-1] == '\n')
! 	{
! 	    if (p > 1 && w[p-2] == '\015') w[p-2] = '\0';
! 	    else w[p-1] = '\0';
! 	}
! 
!         if(w[0] == '\0') {
! 	    kill_timeout (r);
! 	    return OK;
! 	}
!                                    
! 	/* if we see a bogus header don't ignore it. Shout and scream */
! 	
!         if(!(l = strchr(w,':'))) {
! 	    char malformed[(sizeof MALFORMED_MESSAGE)+1+MALFORMED_HEADER_LENGTH_TO_SHOW];
!             strcpy(malformed, MALFORMED_MESSAGE);
!             strncat(malformed, w, MALFORMED_HEADER_LENGTH_TO_SHOW);
!             /* Soak up all the script output --- may save an outright kill */
! 	    while (bgets(w, MAX_STRING_LEN-1, fb) != NULL)
! 	        continue;
! 	    
! 	    kill_timeout (r);
! 	    log_reason (malformed, r->filename, r);
! 	    return SERVER_ERROR;
!         }
! 
!         *l++ = '\0';
! 	while (*l && isspace (*l)) ++l;
! 	
!         if(!strcasecmp(w,"Content-type")) {
! 
! 	    /* Nuke trailing whitespace */
! 	    
! 	    char *endp = l + strlen(l) - 1;
! 	    while (endp > l && isspace(*endp)) *endp-- = '\0';
! 	    
! 	    r->content_type = pstrdup (r->pool, l);
! 	}
!         else if(!strcasecmp(w,"Status")) {
!             sscanf(l, "%d", &r->status);
!             r->status_line = pstrdup(r->pool, l);
!         }
!         else if(!strcasecmp(w,"Location")) {
! 	    table_set (r->headers_out, w, l);
!         }   
! 
! /* The HTTP specification says that it is legal to merge duplicate
!  * headers into one.  Some browsers that support Cookies don't like
!  * merged headers and prefer that each Set-Cookie header is sent
!  * separately.  Lets humour those browsers.
!  */
! 	else if(!strcasecmp(w, "Set-Cookie")) {
! 	    table_add(r->err_headers_out, w, l);
! 	}
!         else {
! 	    table_merge (r->err_headers_out, w, l);
!         }
!     }
! }
! 
! int
! scan_script_header(request_rec *r, FILE *f)
! {
!     char w[MAX_STRING_LEN];
!     char *l;
!     int p;
! 
!     hard_timeout ("read script header", r);
!     
!     while(1) {
! 
!         if (fgets(w, MAX_STRING_LEN-1, f) == NULL) {
  	    log_reason ("Premature end of script headers", r->filename, r);
  	    return SERVER_ERROR;
          }

Mime
View raw message