apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From stodd...@apache.org
Subject cvs commit: apr-util/buckets apr_buckets_file.c
Date Wed, 07 Feb 2001 15:24:24 GMT
stoddard    01/02/07 07:24:24

  Modified:    buckets  apr_buckets_file.c
  Log:
  Fix a leaky bucket. Leaking an apr_file_t and an apr_bucket_shared struct when we converted
a file
  bucket into a heap bucket
  
  Revision  Changes    Path
  1.27      +13 -11    apr-util/buckets/apr_buckets_file.c
  
  Index: apr_buckets_file.c
  ===================================================================
  RCS file: /home/cvs/apr-util/buckets/apr_buckets_file.c,v
  retrieving revision 1.26
  retrieving revision 1.27
  diff -u -r1.26 -r1.27
  --- apr_buckets_file.c	2001/02/02 21:02:19	1.26
  +++ apr_buckets_file.c	2001/02/07 15:24:24	1.27
  @@ -85,6 +85,17 @@
   #endif /* APR_HAS_MMAP */
   
   
  +static void file_destroy(void *data)
  +{
  +    apr_bucket_file *f;
  +
  +    f = apr_bucket_destroy_shared(data);
  +    if (f == NULL) {
  +        return;
  +    }
  +    free(f);
  +}
  +
   /* XXX: We should obey the block flag */
   static apr_status_t file_read(apr_bucket *e, const char **str,
   			      apr_size_t *len, apr_read_type_e block)
  @@ -117,6 +128,7 @@
       }
       if (mm) {
           apr_bucket_make_mmap(e, mm, 0, e->length); /*XXX: check for failure? */
  +        file_destroy(s);
           return apr_bucket_read(e, str, len, block);
       }
       else {
  @@ -152,6 +164,7 @@
            * even if we read nothing because we hit EOF.
            */
           apr_bucket_make_heap(e, buf, *len, 0, NULL); /*XXX: check for failure? */
  +        file_destroy(s);
   
           /* If we have more to read from the file, then create another bucket */
           if (length > 0) {
  @@ -162,17 +175,6 @@
       }
   #endif
       return APR_SUCCESS;
  -}
  -
  -static void file_destroy(void *data)
  -{
  -    apr_bucket_file *f;
  -
  -    f = apr_bucket_destroy_shared(data);
  -    if (f == NULL) {
  -        return;
  -    }
  -    free(f);
   }
   
   APU_DECLARE(apr_bucket *) apr_bucket_make_file(apr_bucket *b, apr_file_t *fd,
  
  
  

Mime
View raw message