apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jwool...@apache.org
Subject cvs commit: apr-util/include apr_buckets.h
Date Wed, 27 Jun 2001 20:15:07 GMT
jwoolley    01/06/27 13:15:07

  Modified:    .        CHANGES
               buckets  apr_buckets_file.c
               include  apr_buckets.h
  Log:
  apr_bucket_file_create() and apr_bucket_file_make() now take a pool
  parameter which is the pool into which any needed data structures
  should be created during file_read().  This is used for MMAPing the
  file and reopening the file if the original apr_file_t is in XTHREAD
  mode.
  
  The end result is that file buckets now correctly support XTHREAD files,
  even if the platform does not handle them natively.
  
  Revision  Changes    Path
  1.22      +6 -0      apr-util/CHANGES
  
  Index: CHANGES
  ===================================================================
  RCS file: /home/cvs/apr-util/CHANGES,v
  retrieving revision 1.21
  retrieving revision 1.22
  diff -u -d -u -r1.21 -r1.22
  --- CHANGES	2001/06/13 16:48:41	1.21
  +++ CHANGES	2001/06/27 20:14:58	1.22
  @@ -1,5 +1,11 @@
   Changes with APR-util b1  
   
  +  *) apr_bucket_file_create() and apr_bucket_file_make() now take a pool
  +     parameter which is the pool into which any needed data structures
  +     should be created during file_read().  This is used for MMAPing the
  +     file and reopening the file if the original apr_file_t is in XTHREAD
  +     mode.  [Cliff Woolley]
  +
     *) apr_brigade_partition() now returns an apr_status_t. [Cliff Woolley]
   
     *) Add MD4 implementation in crypto.  [Sander Striker, Justin Erenkrantz]
  
  
  
  1.48      +28 -4     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.47
  retrieving revision 1.48
  diff -u -d -u -r1.47 -r1.48
  --- apr_buckets_file.c	2001/06/27 15:56:06	1.47
  +++ apr_buckets_file.c	2001/06/27 20:15:01	1.48
  @@ -132,13 +132,30 @@
       apr_status_t rv;
       apr_off_t filelength = e->length;  /* bytes remaining in file past offset */
       apr_off_t fileoffset = e->start;
  +    apr_int32_t flags;
   
   #if APR_HAS_MMAP
  -    if (file_make_mmap(e, filelength, fileoffset, apr_file_pool_get(f))) {
  +    if (file_make_mmap(e, filelength, fileoffset, a->readpool)) {
           return apr_bucket_read(e, str, len, block);
       }
   #endif
   
  +#if APR_HAS_THREADS && !APR_HAS_XTHREAD_FILES
  +    if ((flags = apr_file_flags_get(f)) & APR_XTHREAD) {
  +        /* this file descriptor is shared across multiple threads and
  +         * this OS doesn't support that natively, so as a workaround
  +         * we must reopen the file into a->readpool */
  +        const char *fname;
  +        apr_file_name_get(&fname, f);
  +
  +        rv = apr_file_open(&f, fname, (flags & ~APR_XTHREAD), 0, a->readpool);
  +        if (rv != APR_SUCCESS)
  +            return rv;
  +
  +        a->fd = f;
  +    }
  +#endif
  +
       *len = (filelength > APR_BUCKET_BUFF_SIZE)
                  ? APR_BUCKET_BUFF_SIZE
                  : filelength;
  @@ -185,7 +202,8 @@
   }
   
   APU_DECLARE(apr_bucket *) apr_bucket_file_make(apr_bucket *b, apr_file_t *fd,
  -                                            apr_off_t offset, apr_size_t len)
  +                                               apr_off_t offset,
  +                                               apr_size_t len, apr_pool_t *p)
   {
       apr_bucket_file *f;
   
  @@ -194,6 +212,7 @@
           return NULL;
       }
       f->fd = fd;
  +    f->readpool = p;
   
       b = apr_bucket_shared_make(b, f, offset, len);
       b->type = &apr_bucket_type_file;
  @@ -202,12 +221,13 @@
   }
   
   APU_DECLARE(apr_bucket *) apr_bucket_file_create(apr_file_t *fd,
  -                                              apr_off_t offset, apr_size_t len)
  +                                                 apr_off_t offset,
  +                                                 apr_size_t len, apr_pool_t *p)
   {
       apr_bucket *b = (apr_bucket *)malloc(sizeof(*b));
   
       APR_BUCKET_INIT(b);
  -    return apr_bucket_file_make(b, fd, offset, len);
  +    return apr_bucket_file_make(b, fd, offset, len, p);
   }
   
   static apr_status_t file_setaside(apr_bucket *data, apr_pool_t *reqpool)
  @@ -223,6 +243,10 @@
   
       if (apr_pool_is_ancestor(curpool, reqpool)) {
           return APR_SUCCESS;
  +    }
  +
  +    if (!apr_pool_is_ancestor(a->readpool, reqpool)) {
  +        a->readpool = reqpool;
       }
   
   #if APR_HAS_MMAP
  
  
  
  1.101     +16 -8     apr-util/include/apr_buckets.h
  
  Index: apr_buckets.h
  ===================================================================
  RCS file: /home/cvs/apr-util/include/apr_buckets.h,v
  retrieving revision 1.100
  retrieving revision 1.101
  diff -u -d -u -r1.100 -r1.101
  --- apr_buckets.h	2001/06/22 12:04:50	1.100
  +++ apr_buckets.h	2001/06/27 20:15:05	1.101
  @@ -581,6 +581,9 @@
       apr_bucket_refcount  refcount;
       /** The file this bucket refers to */
       apr_file_t *fd;
  +    /** The pool into which any needed structures should
  +     *  be created while reading from this file bucket */
  +    apr_pool_t *readpool;
   };
   
   /*  *****  Bucket Brigade Functions  *****  */
  @@ -1265,12 +1268,15 @@
    * @param fd The file to put in the bucket
    * @param offset The offset where the data of interest begins in the file
    * @param len The amount of data in the file we are interested in
  + * @param p The pool into which any needed structures should be created
  + *          while reading from this file bucket
    * @return The new bucket, or NULL if allocation failed
  - * @deffunc apr_bucket *apr_bucket_file_create(apr_file_t *fd, apr_off_t offset, apr_size_t
len)
  + * @deffunc apr_bucket *apr_bucket_file_create(apr_file_t *fd, apr_off_t offset, apr_size_t
len, apr_pool_t *p)
    */
  -APU_DECLARE(apr_bucket *) 
  -                apr_bucket_file_create(apr_file_t *fd, apr_off_t offset,
  -                                      apr_size_t len);
  +APU_DECLARE(apr_bucket *) apr_bucket_file_create(apr_file_t *fd,
  +                                                 apr_off_t offset,
  +                                                 apr_size_t len,
  +                                                 apr_pool_t *p);
   
   /**
    * Make the bucket passed in a bucket refer to a file
  @@ -1278,12 +1284,14 @@
    * @param fd The file to put in the bucket
    * @param offset The offset where the data of interest begins in the file
    * @param len The amount of data in the file we are interested in
  + * @param p The pool into which any needed structures should be created
  + *          while reading from this file bucket
    * @return The new bucket, or NULL if allocation failed
  - * @deffunc apr_bucket *apr_bucket_file_make(apr_bucket *b, apr_file_t *fd, apr_off_t offset,
apr_size_t len)
  + * @deffunc apr_bucket *apr_bucket_file_make(apr_bucket *b, apr_file_t *fd, apr_off_t offset,
apr_size_t len, apr_pool_t *p)
    */
  -APU_DECLARE(apr_bucket *) 
  -                apr_bucket_file_make(apr_bucket *b, apr_file_t *fd,
  -                                    apr_off_t offset, apr_size_t len);
  +APU_DECLARE(apr_bucket *) apr_bucket_file_make(apr_bucket *b, apr_file_t *fd,
  +                                               apr_off_t offset,
  +                                               apr_size_t len, apr_pool_t *p);
   
   #ifdef __cplusplus
   }
  
  
  

Mime
View raw message