httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r..@locus.apache.org
Subject cvs commit: apache-2.0/src/modules/standard mod_cgi.c
Date Wed, 01 Mar 2000 16:21:22 GMT
rbb         00/03/01 08:21:22

  Modified:    src/lib/apr/file_io/unix pipe.c readwrite.c
               src/lib/apr/test Makefile.in
               src/main iol_file.c
               src/modules/standard mod_cgi.c
  Added:       src/lib/apr/test testpipe.c
  Log:
  Add a test program for pipes.  Add support for non-buffered CGI's to mod_cgi.
  This still doesn't terminate CGI's after a time limit, that's the next step.
  
  Revision  Changes    Path
  1.12      +1 -2      apache-2.0/src/lib/apr/file_io/unix/pipe.c
  
  Index: pipe.c
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/lib/apr/file_io/unix/pipe.c,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- pipe.c	2000/02/21 18:29:31	1.11
  +++ pipe.c	2000/03/01 16:21:14	1.12
  @@ -58,9 +58,8 @@
   static ap_status_t pipenonblock(struct file_t *thefile)
   {
   #ifndef BEOS /* this code won't work on BeOS */
  -    int fd_flags;
  +    int fd_flags = fcntl(thefile->filedes, F_GETFL, 0);
   
  -    fd_flags = fcntl(thefile->filedes, F_GETFL, 0);
   #if defined(O_NONBLOCK)
       fd_flags |= O_NONBLOCK;
   #elif defined(O_NDELAY)
  
  
  
  1.22      +5 -1      apache-2.0/src/lib/apr/file_io/unix/readwrite.c
  
  Index: readwrite.c
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/lib/apr/file_io/unix/readwrite.c,v
  retrieving revision 1.21
  retrieving revision 1.22
  diff -u -r1.21 -r1.22
  --- readwrite.c	2000/02/21 16:41:40	1.21
  +++ readwrite.c	2000/03/01 16:21:14	1.22
  @@ -119,7 +119,11 @@
           }  
       }  /* buffered? */
   
  -    if ((*nbytes != rv) && (errno != EINTR) && !thefile->buffered) {
  +    /* getting less data than requested does not signify an EOF when
  +       dealing with a pipe.
  +     */
  +    if ((*nbytes != rv) && ((errno == EPIPE && thefile->pipe == 1)
  +        || (errno != EINTR && !thefile->buffered && thefile->pipe
== 0 ))) {
           thefile->eof_hit = 1;
       }
       *nbytes = rv;
  
  
  
  1.12      +5 -1      apache-2.0/src/lib/apr/test/Makefile.in
  
  Index: Makefile.in
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/lib/apr/test/Makefile.in,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- Makefile.in	2000/01/27 23:49:34	1.11
  +++ Makefile.in	2000/03/01 16:21:17	1.12
  @@ -23,7 +23,8 @@
   	ab@EXEEXT@ \
   	htdigest@EXEEXT@ \
   	testmmap@EXEEXT@ \
  -	testshmem@EXEEXT@
  +	testshmem@EXEEXT@ \
  +	testpipe@EXEEXT@
   
   OBJS= testfile.o \
   	testproc.o \
  @@ -75,6 +76,9 @@
   
   testshmem@EXEEXT@: testshmem.o
   	$(CC) $(CFLAGS) testshmem.o -o testshmem@EXEEXT@ $(LDFLAGS)
  +
  +testpipe@EXEEXT@: testpipe.o
  +	$(CC) $(CFLAGS) testpipe.o -o testpipe@EXEEXT@ $(LDFLAGS)
   
   clean:
   	$(RM) -f *.o *.a *.so $(TARGETS)
  
  
  
  1.1                  apache-2.0/src/lib/apr/test/testpipe.c
  
  Index: testpipe.c
  ===================================================================
  /* ====================================================================
   * Copyright (c) 1999 The Apache Group.  All rights reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer. 
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. All advertising materials mentioning features or use of this
   *    software must display the following acknowledgment:
   *    "This product includes software developed by the Apache Group
   *    for use in the Apache HTTP server project (http://www.apache.org/)."
   *
   * 4. The names "Apache Server" and "Apache Group" must not be used to
   *    endorse or promote products derived from this software without
   *    prior written permission. For written permission, please contact
   *    apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * 6. Redistributions of any form whatsoever must retain the following
   *    acknowledgment:
   *    "This product includes software developed by the Apache Group
   *    for use in the Apache HTTP server project (http://www.apache.org/)."
   *
   * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
   * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
   * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE APACHE GROUP OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
   * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
   * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
   * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
   * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
   * OF THE POSSIBILITY OF SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Group.
   * For more information on the Apache Group and the Apache HTTP server
   * project, please see <http://www.apache.org/>.
   *
   */
  #include <stdio.h>
  #include "apr_file_io.h"
  #include "apr_errno.h"
  #include "apr_general.h"
  #include "apr_lib.h"
  #ifdef BEOS
  #include <unistd.h>
  #endif
  
  int test_filedel(ap_context_t *);
  int testdirs(ap_context_t *);
  
  int main()
  {
      ap_context_t *context;
      ap_file_t *readp = NULL;
      ap_file_t *writep = NULL;
      ap_status_t status = 0;
      ap_size_t nbytes;
      char *buf;
  
      if (ap_create_context(&context, NULL) != APR_SUCCESS) {
          fprintf(stderr, "Couldn't allocate context.");
          exit(-1);
      }
  
      fprintf(stdout, "Testing pipe functions.\n");
  
      fprintf(stdout, "\tCreating pipes.......");
      if (ap_create_pipe(&readp, &writep, context) != APR_SUCCESS) {
          perror("Didn't create the pipe");
          exit(-1);
      }
      else {
          fprintf(stdout, "OK\n");
      }
      
      fprintf(stdout, "\tSetting pipe timeout.......");
      if (ap_set_pipe_timeout(readp, 1) != APR_SUCCESS) {
          perror("Couldn't set a timeout");
          exit(-1);
      } else {
          fprintf(stdout, "OK\n");
      }        
  
      fprintf(stdout, "\tReading from the file.......");
      nbytes = (ap_ssize_t)strlen("this is a test");
      buf = (char *)ap_palloc(context, nbytes + 1);
      if (ap_read(readp, buf, &nbytes) == APR_TIMEUP) {
          fprintf(stdout, "OK\n");
      }
      else {
          fprintf(stdout, "The timeout didn't work  :-(\n");
          exit(-1);
      }
  
      return 1;
  }
  
  
  
  1.10      +8 -1      apache-2.0/src/main/iol_file.c
  
  Index: iol_file.c
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/main/iol_file.c,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- iol_file.c	2000/02/21 16:41:41	1.9
  +++ iol_file.c	2000/03/01 16:21:20	1.10
  @@ -115,7 +115,14 @@
   static ap_status_t file_setopt(ap_iol *viol, ap_iol_option opt,
                                  const void *value)
   {
  -    return APR_EINVAL;
  +    iol_file *iol = (iol_file *)viol;
  +
  +    switch (opt) {
  +    case AP_IOL_TIMEOUT:
  +        return ap_set_pipe_timeout(iol->file, *(const int*)value);
  +    default:
  +        return APR_EINVAL;
  +    }
   }
   
   static ap_status_t file_getopt(ap_iol *viol, ap_iol_option opt, void *value)
  
  
  
  1.29      +3 -3      apache-2.0/src/modules/standard/mod_cgi.c
  
  Index: mod_cgi.c
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/modules/standard/mod_cgi.c,v
  retrieving revision 1.28
  retrieving revision 1.29
  diff -u -r1.28 -r1.29
  --- mod_cgi.c	2000/02/13 00:39:04	1.28
  +++ mod_cgi.c	2000/03/01 16:21:21	1.29
  @@ -331,9 +331,9 @@
        */
       if (((rc = ap_createprocattr_init(&procattr, p)) != APR_SUCCESS) ||
           ((rc = ap_setprocattr_io(procattr, 
  -                                 APR_FULL_BLOCK, 
  -                                 APR_FULL_BLOCK,
  -                                 APR_FULL_BLOCK)) != APR_SUCCESS) ||
  +                                 APR_CHILD_BLOCK, 
  +                                 APR_CHILD_BLOCK,
  +                                 APR_CHILD_BLOCK)) != APR_SUCCESS) ||
           ((rc = ap_setprocattr_dir(procattr, 
                                     ap_make_dirstr_parent(r->pool, r->filename))) !=
APR_SUCCESS) ||
           ((rc = ap_setprocattr_cmdtype(procattr, APR_PROGRAM)) != APR_SUCCESS)) {
  
  
  

Mime
View raw message