jwoolley 01/11/28 17:20:56
Modified: . CHANGES
buckets apr_buckets_file.c apr_buckets_mmap.c
Log:
Reading a file bucket bigger than APR_MMAP_LIMIT (4MB) now yields
a string of 4MB mmap buckets, rather than a string of 8KB heap buckets
plus a 4MB mmap bucket. To accomodate this, the mmap bucket destroy
function explicitly deletes the apr_mmap_t after last reference
to avoid having too much of a large file mapped at once if possible.
This was made possible by the newly-added "owner" logic in the APR mmap
code.
Revision Changes Path
1.40 +9 -1 apr-util/CHANGES
Index: CHANGES
===================================================================
RCS file: /home/cvs/apr-util/CHANGES,v
retrieving revision 1.39
retrieving revision 1.40
diff -u -d -u -r1.39 -r1.40
--- CHANGES 2001/11/28 17:34:17 1.39
+++ CHANGES 2001/11/29 01:20:56 1.40
@@ -1,7 +1,15 @@
Changes with APR-util b1
+
+ *) Reading a file bucket bigger than APR_MMAP_LIMIT (4MB) now yields
+ a string of 4MB mmap buckets, rather than a string of 8KB heap buckets
+ plus a 4MB mmap bucket. To accomodate this, the mmap bucket destroy
+ function explicitly deletes the apr_mmap_t after last reference
+ to avoid having too much of a large file mapped at once if possible.
+ [Cliff Woolley]
+
*) Multi-DBM support (via apr_dbm_open_ex [Ian Holsman])
- *) Use apr_mmap_dup in MMap Bucket [Brian Pane <[EMAIL PROTECTED]>]
+ *) Use apr_mmap_dup in mmap_setaside(). [Brian Pane <[EMAIL PROTECTED]>]
*) Dropped the "w" parameter from apr_bucket_heap_create() and
apr_bucket_heap_make(). That parameter was originally intended
1.62 +17 -7 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.61
retrieving revision 1.62
diff -u -d -u -r1.61 -r1.62
--- apr_buckets_file.c 2001/11/28 00:38:00 1.61
+++ apr_buckets_file.c 2001/11/29 01:20:56 1.62
@@ -84,15 +84,25 @@
apr_bucket_file *a = e->data;
apr_mmap_t *mm;
- if (APR_MMAP_CANDIDATE(filelength) &&
- (apr_mmap_create(&mm, a->fd, fileoffset, filelength,
- APR_MMAP_READ, p) == APR_SUCCESS))
+ if (filelength > APR_MMAP_LIMIT) {
+ if (apr_mmap_create(&mm, a->fd, fileoffset, APR_MMAP_LIMIT,
+ APR_MMAP_READ, p) != APR_SUCCESS) {
+ return 0;
+ }
+ else {
+ apr_bucket_split(e, APR_MMAP_LIMIT);
+ filelength = APR_MMAP_LIMIT;
+ }
+ }
+ else if ((filelength >= APR_MMAP_THRESHOLD) &&
+ (apr_mmap_create(&mm, a->fd, fileoffset, filelength,
+ APR_MMAP_READ, p) != APR_SUCCESS))
{
- apr_bucket_mmap_make(e, mm, 0, filelength);
- file_destroy(a);
- return 1;
+ return 0;
}
- return 0;
+ apr_bucket_mmap_make(e, mm, 0, filelength);
+ file_destroy(a);
+ return 1;
}
#endif
1.45 +3 -2 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.44
retrieving revision 1.45
diff -u -d -u -r1.44 -r1.45
--- apr_buckets_mmap.c 2001/11/21 17:00:51 1.44
+++ apr_buckets_mmap.c 2001/11/29 01:20:56 1.45
@@ -80,8 +80,9 @@
apr_bucket_mmap *m = data;
if (apr_bucket_shared_destroy(m)) {
- /* no need to apr_mmap_delete(m->mmap) here... it will
- * get done automatically when the pool gets cleaned up. */
+ /* if we are the owner of the mmaped region, apr_mmap_delete will
+ * munmap it for us. if we're not, it's essentially a noop. */
+ apr_mmap_delete(m->mmap);
free(m);
}
}