You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@apr.apache.org by dr...@apache.org on 2001/01/29 20:01:29 UTC
cvs commit: apr/mmap/unix mmap.c
dreid 01/01/29 11:01:28
Modified: mmap/unix mmap.c
Log:
Get this working on beos again so we can serve pages!
Some of the code improvements were suggested by Carlos Hasan
<ch...@acm.org>.
Revision Changes Path
1.30 +9 -7 apr/mmap/unix/mmap.c
Index: mmap.c
===================================================================
RCS file: /home/cvs/apr/mmap/unix/mmap.c,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -r1.29 -r1.30
--- mmap.c 2000/12/08 04:28:54 1.29
+++ mmap.c 2001/01/29 19:01:25 1.30
@@ -109,7 +109,6 @@
#ifdef BEOS
void *mm;
area_id aid = -1;
- char *areaname = "apr_mmap\0";
uint32 pages = 0;
#else
caddr_t mm;
@@ -122,8 +121,6 @@
#ifdef BEOS
/* XXX: mmap shouldn't really change the seek offset */
apr_seek(file, APR_SET, &offset);
- pages = ((size -1) / B_PAGE_SIZE) + 1;
-
if (flag & APR_MMAP_WRITE) {
native_flags |= B_WRITE_AREA;
}
@@ -131,16 +128,21 @@
native_flags |= B_READ_AREA;
}
- aid = create_area(areaname, &mm , B_ANY_ADDRESS, pages * B_PAGE_SIZE,
- B_FULL_LOCK, native_flags);
+ /* There seems to be some strange interactions that mean our area must
+ * be set as READ & WRITE or writev will fail! Go figure...
+ */
+ pages = (size + B_PAGE_SIZE -1) / B_PAGE_SIZE;
+ aid = create_area("apr_mmap", &mm , B_ANY_ADDRESS, pages * B_PAGE_SIZE,
+ B_NO_LOCK, B_WRITE_AREA|B_READ_AREA);
if (aid < B_NO_ERROR) {
- /* we failed to get an mmap'd file... */
+ /* we failed to get an area we can use... */
return APR_ENOMEM;
}
if (aid >= B_NO_ERROR)
read(file->filedes, mm, size);
+
(*new)->area = aid;
#else
@@ -162,7 +164,7 @@
(*new)->mm = mm;
(*new)->size = size;
(*new)->cntxt = cont;
-
+
/* register the cleanup... */
apr_register_cleanup((*new)->cntxt, (void*)(*new), mmap_cleanup,
apr_null_cleanup);