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 Fri, 25 Jan 2002 07:12:37 GMT
wrowe       02/01/24 23:12:37

  Modified:    include  apr_portable.h
               shmem/win32 shm.c
  Log:
    Win32 requires an apr_os accessor for shm regions.  This allows us to
    take the handle and do interesting things, such as passing it (after
    duping it) into the child.
  
    Unix implementation is simply the address of the shm region, AFAICT,
    but Aaron is reviewing.
  
  Revision  Changes    Path
  1.73      +28 -0     apr/include/apr_portable.h
  
  Index: apr_portable.h
  ===================================================================
  RCS file: /home/cvs/apr/include/apr_portable.h,v
  retrieving revision 1.72
  retrieving revision 1.73
  diff -u -r1.72 -r1.73
  --- apr_portable.h	8 Jan 2002 06:26:09 -0000	1.72
  +++ apr_portable.h	25 Jan 2002 07:12:37 -0000	1.73
  @@ -78,6 +78,7 @@
   #include "apr_proc_mutex.h"
   #include "apr_time.h"
   #include "apr_dso.h"
  +#include "apr_shm.h"
   
   #if APR_HAVE_DIRENT_H
   #include <dirent.h>
  @@ -107,6 +108,7 @@
   typedef FILETIME              apr_os_imp_time_t;
   typedef SYSTEMTIME            apr_os_exp_time_t;
   typedef HANDLE                apr_os_dso_handle_t;
  +typedef HANDLE                apr_os_shm_t;
   
   #elif defined(OS2)
   typedef HFILE                 apr_os_file_t;
  @@ -121,6 +123,7 @@
   typedef struct timeval        apr_os_imp_time_t;
   typedef struct tm             apr_os_exp_time_t;
   typedef HMODULE               apr_os_dso_handle_t;
  +typedef void*                 apr_os_shm_t;
   
   #elif defined(__BEOS__)
   #include <kernel/OS.h>
  @@ -143,6 +146,7 @@
   typedef struct timeval        apr_os_imp_time_t;
   typedef struct tm             apr_os_exp_time_t;
   typedef image_id              apr_os_dso_handle_t;
  +typedef void*                 apr_os_shm_t;
   
   #elif defined(NETWARE)
   typedef int                   apr_os_file_t;
  @@ -157,6 +161,7 @@
   typedef struct timeval        apr_os_imp_time_t;
   typedef struct tm             apr_os_exp_time_t;
   typedef void *                apr_os_dso_handle_t;
  +typedef void*                 apr_os_shm_t;
   
   #else
   /* Any other OS should go above this one.  This is the lowest common
  @@ -201,6 +206,7 @@
   #else
   typedef void *                apr_os_dso_handle_t;
   #endif
  +typedef void*                 apr_os_shm_t;
   
   #endif
   
  @@ -280,6 +286,14 @@
   APR_DECLARE(apr_status_t) apr_os_imp_time_get(apr_os_imp_time_t **ostime, 
                                                 apr_time_t *aprtime);
   
  +/**
  + * convert the shm from apr type to os specific type.
  + * @param osshm The os specific shm representation
  + * @param shm The apr shm to convert.
  + */   
  +APR_DECLARE(apr_status_t) apr_os_shm_get(apr_os_shm_t *osshm,
  +                                         apr_shm_t *shm);
  +
   #if APR_HAS_THREADS || defined(DOXYGEN)
   /** 
    * @defgroup APR_PORT_Thread Thread portability Routines
  @@ -423,6 +437,19 @@
                                                 apr_os_exp_time_t **ostime,
                                                 apr_pool_t *cont); 
   
  +/**
  + * convert the shared memory from os specific type to apr type.
  + * @param shm The apr shm representation of osshm
  + * @param osshm The os specific shm identity
  + * @param cont The pool to use if it is needed.
  + * @remark On fork()ed architectures, this is typically nothing more than
  + * the memory block mapped.  On non-fork architectures, this is typically
  + * some internal handle to pass the mapping from process to process.
  + */
  +APR_DECLARE(apr_status_t) apr_os_shm_put(apr_shm_t **shm,
  +                                         apr_os_shm_t *osshm,
  +                                         apr_pool_t *cont); 
  +
   
   #if APR_HAS_DSO || defined(DOXYGEN)
   /** 
  @@ -448,6 +475,7 @@
                                                   apr_dso_handle_t *aprdso);
   /** @} */
   #endif /* APR_HAS_DSO */
  +
   
   #ifdef __cplusplus
   }
  
  
  
  1.7       +32 -0     apr/shmem/win32/shm.c
  
  Index: shm.c
  ===================================================================
  RCS file: /home/cvs/apr/shmem/win32/shm.c,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- shm.c	24 Jan 2002 07:45:36 -0000	1.6
  +++ shm.c	25 Jan 2002 07:12:37 -0000	1.7
  @@ -264,3 +264,35 @@
   {
       return m->length;
   }
  +
  +APR_DECLARE(apr_status_t) apr_os_shm_get(apr_os_shm_t *osshm,
  +                                         apr_shm_t *shm)
  +{
  +    *osshm = shm->hMap;
  +    return APR_SUCCESS;
  +}
  +
  +APR_DECLARE(apr_status_t) apr_os_shm_put(apr_shm_t **m,
  +                                         apr_os_shm_t *osshm,
  +                                         apr_pool_t *pool)
  +{
  +    void* base;
  +    base = MapViewOfFile(*osshm, FILE_MAP_READ | FILE_MAP_WRITE, 0, 0, 0);
  +    if (!base) {
  +        return apr_get_os_error();
  +    }
  +    
  +    *m = (apr_shm_t *) apr_palloc(pool, sizeof(apr_shm_t));
  +    (*m)->pool = pool;
  +    (*m)->hMap = *osshm;
  +    (*m)->memblk = base;
  +    (*m)->usrmem = (char*)base + sizeof(memblock_t);
  +    /* Real (*m)->mem->size could be recovered with VirtualQuery */
  +    (*m)->size = (*m)->memblk->size;
  +    (*m)->length = (*m)->memblk->length;
  +
  +    apr_pool_cleanup_register((*m)->pool, *m, 
  +                              shm_cleanup, apr_pool_cleanup_null);
  +    return APR_SUCCESS;
  +}    
  +
  
  
  

Mime
View raw message