apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wr...@apache.org
Subject cvs commit: apr/shmem/win32 shm.c
Date Thu, 10 Jan 2002 00:09:17 GMT
wrowe       02/01/09 16:09:17

  Modified:    shmem/win32 shm.c
  Log:
    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
  
  Revision  Changes    Path
  1.4       +8 -16     apr/shmem/win32/shm.c
  
  Index: shm.c
  ===================================================================
  RCS file: /home/cvs/apr/shmem/win32/shm.c,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- shm.c	9 Jan 2002 04:35:10 -0000	1.3
  +++ shm.c	10 Jan 2002 00:09:17 -0000	1.4
  @@ -99,6 +99,7 @@
       apr_file_t *f;
       void *base;
       void *mapkey;
  +    DWORD err;
   
       reqsize += sizeof(memblock_t);
   
  @@ -128,12 +129,13 @@
            * 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 @@
   #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_attach(apr_shm_t **m,
  -                                         apr_size_t sz,
                                            const char *file,
                                            apr_pool_t *pool)
   {
  
  
  

Mime
View raw message