apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From i...@apache.org
Subject cvs commit: apr-util/buckets apr_buckets_mmap.c
Date Wed, 21 Nov 2001 17:00:52 GMT
ianh        01/11/21 09:00:51

  Modified:    .        CHANGES
               include  apr_mmap.h
               mmap/unix mmap.c
               mmap/win32 mmap.c
               .        CHANGES
               buckets  apr_buckets_mmap.c
  Log:
  New APR function apr_mmap_dup.
  this is used in the MMAP bucket setaside function for a performance win.
  Mod_file_cache will also use this
  Submitted by:	Brian Pane <bpane@pacbell.net>
  
  Revision  Changes    Path
  1.186     +5 -0      apr/CHANGES
  
  Index: CHANGES
  ===================================================================
  RCS file: /home/cvs/apr/CHANGES,v
  retrieving revision 1.185
  retrieving revision 1.186
  diff -u -r1.185 -r1.186
  --- CHANGES	2001/11/20 19:00:39	1.185
  +++ CHANGES	2001/11/21 17:00:50	1.186
  @@ -1,4 +1,9 @@
   Changes with APR b1  
  +  *)  New function apr_mmap_dup. This is called in the mmap_setaside 
  +      [Brain Pane <bpane@pacbell.net>]
  +
  +  *)  speed up the apr_hash_t implementation's handling of APR_HASH_KEY_STRING.
  +      [Brain Pane <bpane@pacbell.net>]
   
     *) Tweak apr_gethostname() so that it detects truncation of the
        name and returns an error.  [Jeff Trawick]
  
  
  
  1.26      +15 -0     apr/include/apr_mmap.h
  
  Index: apr_mmap.h
  ===================================================================
  RCS file: /home/cvs/apr/include/apr_mmap.h,v
  retrieving revision 1.25
  retrieving revision 1.26
  diff -u -r1.25 -r1.26
  --- apr_mmap.h	2001/08/18 15:15:46	1.25
  +++ apr_mmap.h	2001/11/21 17:00:50	1.26
  @@ -111,6 +111,8 @@
       void *mm;
       /** The amount of data in the mmap */
       apr_size_t size;
  +    /** Whether this object is reponsible for doing the munmap */
  +    int is_owner;
   };
   
   #if APR_HAS_MMAP || defined(DOXYGEN)
  @@ -134,6 +136,19 @@
                                             apr_file_t *file, apr_off_t offset,
                                             apr_size_t size, apr_int32_t flag,
                                             apr_pool_t *cntxt);
  +
  +/**
  + * Duplicate the specified MMAP.
  + * @param new_mmap The structure to duplicate into. 
  + * @param old_mmap The file to duplicate.
  + * @param p The pool to use for the new file.
  + * @param transfer_ownership  Whether responsibility for destroying
  + *  the memory-mapped segment is transferred from old_mmap to new_mmap
  + */         
  +APR_DECLARE(apr_status_t) apr_mmap_dup(apr_mmap_t **new_mmap,
  +                                       apr_mmap_t *old_mmap,
  +                                       apr_pool_t *p,
  +                                       int transfer_ownership);
   
   /**
    * Remove a mmap'ed.
  
  
  
  1.37      +32 -0     apr/mmap/unix/mmap.c
  
  Index: mmap.c
  ===================================================================
  RCS file: /home/cvs/apr/mmap/unix/mmap.c,v
  retrieving revision 1.36
  retrieving revision 1.37
  diff -u -r1.36 -r1.37
  --- mmap.c	2001/08/02 04:26:53	1.36
  +++ mmap.c	2001/11/21 17:00:51	1.37
  @@ -83,6 +83,11 @@
   {
       apr_mmap_t *mm = themmap;
       int rv;
  +
  +    if (!mm->is_owner) {
  +        return APR_SUCCESS;
  +    }
  +
   #ifdef BEOS
       rv = delete_area(mm->area);
   
  @@ -159,10 +164,37 @@
       (*new)->mm = mm;
       (*new)->size = size;
       (*new)->cntxt = cont;
  +    (*new)->is_owner = 1;
   
       /* register the cleanup... */
       apr_pool_cleanup_register((*new)->cntxt, (void*)(*new), mmap_cleanup,
                apr_pool_cleanup_null);
  +    return APR_SUCCESS;
  +}
  +
  +APR_DECLARE(apr_status_t) apr_mmap_dup(apr_mmap_t **new_mmap,
  +                                       apr_mmap_t *old_mmap,
  +                                       apr_pool_t *p,
  +                                       int transfer_ownership)
  +{
  +    *new_mmap = (apr_mmap_t *)apr_pmemdup(p, old_mmap, sizeof(apr_mmap_t));
  +    (*new_mmap)->cntxt = p;
  +
  +    /* The old_mmap can transfer ownership only if the old_mmap itself
  +     * is an owner of the mmap'ed segment.
  +     */
  +    if (old_mmap->is_owner) {
  +        if (transfer_ownership) {
  +            (*new_mmap)->is_owner = 1;
  +            old_mmap->is_owner = 0;
  +            apr_pool_cleanup_kill(old_mmap->cntxt, old_mmap, mmap_cleanup);
  +        }
  +        else {
  +            (*new_mmap)->is_owner = 0;
  +        }
  +        apr_pool_cleanup_register(p, *new_mmap, mmap_cleanup,
  +                                  apr_pool_cleanup_null);
  +    }
       return APR_SUCCESS;
   }
   
  
  
  
  1.7       +32 -0     apr/mmap/win32/mmap.c
  
  Index: mmap.c
  ===================================================================
  RCS file: /home/cvs/apr/mmap/win32/mmap.c,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- mmap.c	2001/06/27 22:07:24	1.6
  +++ mmap.c	2001/11/21 17:00:51	1.7
  @@ -66,6 +66,11 @@
   {
       apr_mmap_t *mm = themmap;
       apr_status_t rv = 0;
  +
  +    if (!mm->is_owner) {
  +        return APR_SUCCESS;
  +    }
  +
       if (mm->mv) {
           if (!UnmapViewOfFile(mm->mv))
           {
  @@ -155,10 +160,37 @@
       (*new)->mm = (char*)((*new)->mv) + offset;
       (*new)->size = size;
       (*new)->cntxt = cont;
  +    (*new)->is_owner = 1;
   
       /* register the cleanup... */
       apr_pool_cleanup_register((*new)->cntxt, (void*)(*new), mmap_cleanup,
                            apr_pool_cleanup_null);
  +    return APR_SUCCESS;
  +}
  +
  +APR_DECLARE(apr_status_t) apr_mmap_dup(apr_mmap_t **new_mmap,
  +                                       apr_mmap_t *old_mmap,
  +                                       apr_pool_t *p,
  +                                       int transfer_ownership)
  +{
  +    *new_mmap = (apr_mmap_t *)apr_pmemdup(p, old_mmap, sizeof(apr_mmap_t));
  +    (*new_mmap)->cntxt = p;
  +
  +    /* The old_mmap can transfer ownership only if the old_mmap itself
  +     * is an owner of the mmap'ed segment.
  +     */
  +    if (old_mmap->is_owner) {
  +        if (transfer_ownership) {
  +            (*new_mmap)->is_owner = 1;
  +            old_mmap->is_owner = 0;
  +            apr_pool_cleanup_kill(old_mmap->cntxt, old_mmap, mmap_cleanup);
  +        }
  +        else {
  +            (*new_mmap)->is_owner = 0;
  +        }
  +        apr_pool_cleanup_register(p, *new_mmap, mmap_cleanup,
  +                                  apr_pool_cleanup_null);
  +    }
       return APR_SUCCESS;
   }
   
  
  
  
  1.38      +1 -0      apr-util/CHANGES
  
  Index: CHANGES
  ===================================================================
  RCS file: /home/cvs/apr-util/CHANGES,v
  retrieving revision 1.37
  retrieving revision 1.38
  diff -u -r1.37 -r1.38
  --- CHANGES	2001/11/12 03:22:25	1.37
  +++ CHANGES	2001/11/21 17:00:51	1.38
  @@ -1,4 +1,5 @@
   Changes with APR-util b1  
  +  *) Use apr_mmap_dup in MMap Bucket [Brian Pane <bpane@pacbell.net>]
   
     *) Dropped the "w" parameter from apr_bucket_heap_create() and
        apr_bucket_heap_make().  That parameter was originally intended
  
  
  
  1.44      +3 -9      apr-util/buckets/apr_buckets_mmap.c
  
  Index: apr_buckets_mmap.c
  ===================================================================
  RCS file: /home/cvs/apr-util/buckets/apr_buckets_mmap.c,v
  retrieving revision 1.43
  retrieving revision 1.44
  diff -u -r1.43 -r1.44
  --- apr_buckets_mmap.c	2001/09/22 22:36:07	1.43
  +++ apr_buckets_mmap.c	2001/11/21 17:00:51	1.44
  @@ -121,24 +121,18 @@
   {
       apr_bucket_mmap *m = data->data;
       apr_mmap_t *mm = m->mmap;
  -    char *base;
  -    void *addr;
  +    apr_mmap_t *new_mm;
       apr_status_t ok;
   
       if (apr_pool_is_ancestor(mm->cntxt, p)) {
           return APR_SUCCESS;
       }
   
  -    ok = apr_mmap_offset(&addr, m->mmap, data->start);
  +    ok = apr_mmap_dup(&new_mm, mm, p, 1);
       if (ok != APR_SUCCESS) {
           return ok;
       }
  -
  -    base = apr_palloc(p, data->length);
  -    memcpy(base, addr, data->length);
  -    data = apr_bucket_pool_make(data, base, data->length, p);
  -    mmap_destroy(m);
  -
  +    m->mmap = new_mm;
       return APR_SUCCESS;
   }
   
  
  
  

Mime
View raw message