httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r..@hyperreal.org
Subject cvs commit: apache-2.0/src/lib/apr/file_io/unix filedup.c open.c
Date Mon, 13 Dec 1999 13:57:11 GMT
rbb         99/12/13 05:57:10

  Modified:    src/lib/apr/file_io/unix filedup.c open.c
  Log:
  A bug fix to ap_open_stderr, and a new feature for ap_dupfile.  The previous
  implementation wouldn't let the user supply two file descriptors and make
  them equivalent, it would only allow us to create a new descriptor.  This
  wasn't good enough.  This patch rectifies that problem.
  
  Revision  Changes    Path
  1.7       +16 -5     apache-2.0/src/lib/apr/file_io/unix/filedup.c
  
  Index: filedup.c
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/lib/apr/file_io/unix/filedup.c,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- filedup.c	1999/12/03 15:18:22	1.6
  +++ filedup.c	1999/12/13 13:57:05	1.7
  @@ -64,12 +64,18 @@
   ap_status_t ap_dupfile(struct file_t **new_file, struct file_t *old_file)
   {
       char *buf_oflags;
  -    (*new_file) = (struct file_t *)ap_palloc(old_file->cntxt,
  -                               sizeof(struct file_t));
  -    
  +    int have_file = 0;
  +
       if ((*new_file) == NULL) {
  -        return APR_ENOMEM;
  +        (*new_file) = (struct file_t *)ap_pcalloc(old_file->cntxt,
  +                                   sizeof(struct file_t));
  +        if ((*new_file) == NULL) {
  +            return APR_ENOMEM;
  +        }
  +    } else {
  +        have_file = 1;
       }
  +    
       (*new_file)->cntxt = old_file->cntxt; 
       if (old_file->buffered) {
           switch (old_file->oflags) {
  @@ -89,7 +95,12 @@
                                           old_file->filehand); 
       }
       else {
  -    (*new_file)->filedes = dup(old_file->filedes); 
  +        if (have_file) {
  +            dup2(old_file->filedes, (*new_file)->filedes);
  +        }
  +        else {
  +            (*new_file)->filedes = dup(old_file->filedes); 
  +        }
       }
       (*new_file)->fname = ap_pstrdup(old_file->cntxt, old_file->fname);
       (*new_file)->buffered = old_file->buffered;
  
  
  
  1.27      +2 -1      apache-2.0/src/lib/apr/file_io/unix/open.c
  
  Index: open.c
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/lib/apr/file_io/unix/open.c,v
  retrieving revision 1.26
  retrieving revision 1.27
  diff -u -r1.26 -r1.27
  --- open.c	1999/12/11 20:24:13	1.26
  +++ open.c	1999/12/13 13:57:06	1.27
  @@ -307,12 +307,13 @@
    */
   ap_status_t ap_open_stderr(struct file_t **thefile, ap_context_t *cont)
   {
  -    (*thefile) = ap_palloc(cont, sizeof(ap_os_file_t *));
  +    (*thefile) = ap_pcalloc(cont, sizeof(ap_os_file_t *));
       if ((*thefile) == NULL) {
           return APR_ENOMEM;
       }
       (*thefile)->filedes = STDERR_FILENO;
       (*thefile)->cntxt = cont;
  +    (*thefile)->fname = NULL;
       (*thefile)->filehand = NULL;
       (*thefile)->stated = 0;
       (*thefile)->buffered = 0;
  
  
  

Mime
View raw message