diff options
author | dreid <dreid@13f79535-47bb-0310-9956-ffa450edef68> | 2004-06-29 16:38:16 +0000 |
---|---|---|
committer | dreid <dreid@13f79535-47bb-0310-9956-ffa450edef68> | 2004-06-29 16:38:16 +0000 |
commit | b54117ea4b95fe830ddd6e9849180548a4b6e8cd (patch) | |
tree | 22808e10591d267a99f525a8dbeec3325146f72e | |
parent | b4f0cce024a7d5eb02610ecd225ed0fdb74bcb6a (diff) | |
download | libapr-b54117ea4b95fe830ddd6e9849180548a4b6e8cd.tar.gz |
Continue clearing my TODO list.
This provides for better "naming" of anon areas, adds a missing function
and tidies up some code.
git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@65236 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r-- | shmem/beos/shm.c | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/shmem/beos/shm.c b/shmem/beos/shm.c index 735be3467..d9a0d1399 100644 --- a/shmem/beos/shm.c +++ b/shmem/beos/shm.c @@ -34,19 +34,28 @@ struct apr_shm_t { APR_DECLARE(apr_status_t) apr_shm_create(apr_shm_t **m, apr_size_t reqsize, - const char *file, + const char *filename, apr_pool_t *p) { apr_size_t pagesize; area_id newid; char *addr; + char shname[B_OS_NAME_LENGTH]; (*m) = (apr_shm_t *)apr_pcalloc(p, sizeof(apr_shm_t)); /* we MUST allocate in pages, so calculate how big an area we need... */ pagesize = ((reqsize + B_PAGE_SIZE - 1) / B_PAGE_SIZE) * B_PAGE_SIZE; - newid = create_area("apr_shmem", (void*)&addr, B_ANY_ADDRESS, - pagesize, B_CONTIGUOUS, B_READ_AREA|B_WRITE_AREA); + if (!filename) { + int num = 0; + snprintf(shname, B_OS_NAME_LENGTH, "apr_shmem_%ld", find_thread(NULL)); + while (find_area(shname) >= 0) + snprintf(shname, B_OS_NAME_LENGTH, "apr_shmem_%ld_%d", + find_thread(NULL), num++); + } + newid = create_area(filename ? filename : shname, + (void*)&addr, B_ANY_ADDRESS, + pagesize, B_LAZY_LOCK, B_READ_AREA|B_WRITE_AREA); if (newid < 0) return errno; @@ -72,7 +81,13 @@ APR_DECLARE(apr_status_t) apr_shm_destroy(apr_shm_t *m) APR_DECLARE(apr_status_t) apr_shm_remove(const char *filename, apr_pool_t *pool) { - return APR_ENOTIMPL; + area_id deleteme = find_area(filename); + + if (deleteme == B_NAME_NOT_FOUND) + return APR_EINVAL; + + delete_area(deleteme); + return APR_SUCCESS; } APR_DECLARE(apr_status_t) apr_shm_attach(apr_shm_t **m, @@ -81,10 +96,9 @@ APR_DECLARE(apr_status_t) apr_shm_attach(apr_shm_t **m, { area_info ai; thread_info ti; - area_id deleteme; apr_shm_t *new_m; - - deleteme = find_area(filename); + area_id deleteme = find_area(filename); + if (deleteme == B_NAME_NOT_FOUND) return APR_EINVAL; |