summaryrefslogtreecommitdiff
path: root/shmem
diff options
context:
space:
mode:
authorWilliam A. Rowe Jr <wrowe@apache.org>2002-01-10 00:09:17 +0000
committerWilliam A. Rowe Jr <wrowe@apache.org>2002-01-10 00:09:17 +0000
commitdd0f95d47321fdb847f4868f777c9619b690a899 (patch)
tree8a12b57fda085c1df53ebeb4816879037b900ed6 /shmem
parent2ea5dacb420fc630bb57f3a519afab46b202d49c (diff)
downloadapr-dd0f95d47321fdb847f4868f777c9619b690a899.tar.gz
Fix a bug that appears when specifying the length [inherit the
physical length after apr_file_trunc] and change the api a bit for Aaron's new apr_shm.h git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@62733 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'shmem')
-rw-r--r--shmem/win32/shm.c24
1 files changed, 8 insertions, 16 deletions
diff --git a/shmem/win32/shm.c b/shmem/win32/shm.c
index 3b9f66cb4..c13de77a7 100644
--- a/shmem/win32/shm.c
+++ b/shmem/win32/shm.c
@@ -99,6 +99,7 @@ APR_DECLARE(apr_status_t) apr_shm_create(apr_shm_t **m,
apr_file_t *f;
void *base;
void *mapkey;
+ DWORD err;
reqsize += sizeof(memblock_t);
@@ -128,12 +129,13 @@ APR_DECLARE(apr_status_t) apr_shm_create(apr_shm_t **m,
* we discover we aren't the creator of the file map object.
*/
rv = apr_file_open(&f, file,
- APR_READ | APR_WRITE | APR_BINARY,
+ APR_READ | APR_WRITE | APR_BINARY | APR_CREATE,
APR_UREAD | APR_UWRITE, pool);
if ((rv != APR_SUCCESS)
|| ((rv = apr_os_file_get(&hFile, f)) != APR_SUCCESS)) {
return rv;
}
+ rv = apr_file_trunc(f, size);
mapkey = res_name_from_filename(file, 1, pool);
psec = NULL;
}
@@ -141,30 +143,21 @@ APR_DECLARE(apr_status_t) apr_shm_create(apr_shm_t **m,
#if APR_HAS_UNICODE_FS
if (apr_os_level >= APR_WIN_NT)
{
- hMap = CreateFileMappingW(hFile,
- psec,
- PAGE_READWRITE,
- (DWORD)(size >> 32),
- (DWORD)size,
- mapkey);
+ hMap = CreateFileMappingW(hFile, psec, PAGE_READWRITE, 0, 0, mapkey);
}
else
#endif
{
- hMap = CreateFileMappingA(hFile,
- psec,
- PAGE_READWRITE,
- (DWORD)(size >> 32),
- (DWORD)size,
- mapkey);
+ hMap = CreateFileMappingA(hFile, psec, PAGE_READWRITE, 0, 0, mapkey);
}
+ err = apr_get_os_error();
apr_file_close(f);
- if (hMap && GetLastError() == ERROR_ALREADY_EXISTS) {
+ if (hMap && err == ERROR_ALREADY_EXISTS) {
CloseHandle(hMap);
return APR_EEXIST;
}
if (!hMap) {
- return apr_get_os_error();
+ return err;
}
base = MapViewOfFile(hMap, FILE_MAP_READ | FILE_MAP_WRITE,
@@ -200,7 +193,6 @@ APR_DECLARE(apr_status_t) apr_shm_destroy(apr_shm_t *m)
}
APR_DECLARE(apr_status_t) apr_shm_attach(apr_shm_t **m,
- apr_size_t sz,
const char *file,
apr_pool_t *pool)
{