httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r..@locus.apache.org
Subject cvs commit: apache-2.0/src/modules/mpm/prefork prefork.c
Date Sat, 02 Dec 2000 07:08:13 GMT
rbb         00/12/01 23:08:12

  Modified:    src      CHANGES
               .        CHANGES
               shmem/unix shmem.c
               shmem/unix/mm mm.h mm_alloc.c mm_global.c mm_test.c
               src/modules/mpm/dexter scoreboard.c
               src/modules/mpm/mpmt_pthread scoreboard.c
               src/modules/mpm/perchild scoreboard.c
               src/modules/mpm/prefork prefork.c
  Log:
  MPMs that require multiple segments of shared memory now just use two
  shared memory blocks to ensure that all of the memory is available.  This
  removes the hack that added 80 bytes to each shared memory block.  We
  end up needing two apr_shmem_t variables, because it is difficult to
  determine exactly how much memory will be needed.  MM automatically tries
  to align the shared memory allocations, so we either need to pad the
  shared memory segments, or just use two different segments.  This also
  changes APR and MM to take into account whatever memory those packages
  need to allocate when creating a shared memory segment.  Any memory that
  APR and MM need is automatically added to the size requested by the
  program.
  
  Revision  Changes    Path
  1.353     +11 -0     apache-2.0/src/CHANGES
  
  Index: CHANGES
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/CHANGES,v
  retrieving revision 1.352
  retrieving revision 1.353
  diff -u -r1.352 -r1.353
  --- CHANGES	2000/12/01 07:32:09	1.352
  +++ CHANGES	2000/12/02 07:07:57	1.353
  @@ -1,4 +1,15 @@
   Changes with Apache 2.0a9
  +  *) The MPMs that need multiple segments of shared memory now create
  +     two apr_shmem_t variables, one for each shared memory allocation.
  +     the problem is that we can't determine how much memory will be required
  +     for shared memory allocations once we try to allocate more than one
  +     variable.  The MM code automatically aligns the shared memory allocations,
  +     so we end up needing to pad the amount of shared memory we want based
  +     on how many variables will be allocated out of the shared memory segment.
  +     It is just easier to create a second apr_shmem_t variable, and two
  +     shmem memory blocks.
  +     [Ryan Bloom]
  +
     *) Cleanup the export list a bit.  This creates a single unified list of
        functions exported by APR.  The export list is generated at configure
        time, and that list is then used to generate the exports.c file.
  
  
  
  1.13      +5 -0      apr/CHANGES
  
  Index: CHANGES
  ===================================================================
  RCS file: /home/cvs/apr/CHANGES,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- CHANGES	2000/12/01 21:33:57	1.12
  +++ CHANGES	2000/12/02 07:08:00	1.13
  @@ -1,4 +1,9 @@
   Changes with APR a9
  +  *) Make APR's shared memory routines always allocate enough memory
  +     for the requested segment, the MM internal types, and the APR
  +     internal types.
  +     [Ryan Bloom]
  +
     *) Add APR_SIZE_T_FMT.  Get the other APR_xx_T_FMT variables
        defined properly on AIX.  [Jeff Trawick]
   
  
  
  
  1.15      +1 -1      apr/shmem/unix/shmem.c
  
  Index: shmem.c
  ===================================================================
  RCS file: /home/cvs/apr/shmem/unix/shmem.c,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- shmem.c	2000/08/02 05:26:33	1.14
  +++ shmem.c	2000/12/02 07:08:04	1.15
  @@ -63,7 +63,7 @@
   
   apr_status_t apr_shm_init(struct shmem_t **m, apr_size_t reqsize, const char *file, apr_pool_t
*cont)
   {
  -    MM *newmm = mm_create(reqsize, file);
  +    MM *newmm = mm_create(reqsize + sizeof(*newmm), file, MM_ALLOCATE_ENOUGH);
       if (newmm == NULL) {
           return errno;
       }
  
  
  
  1.9       +4 -1      apr/shmem/unix/mm/mm.h
  
  Index: mm.h
  ===================================================================
  RCS file: /home/cvs/apr/shmem/unix/mm/mm.h,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- mm.h	2000/05/03 17:15:49	1.8
  +++ mm.h	2000/12/02 07:08:06	1.9
  @@ -66,6 +66,9 @@
       MM_LOCK_RD, MM_LOCK_RW
   } mm_lock_mode;
   
  +#define MM_ALLOCATE_ENOUGH 1
  +#define MM_ALLOCATE_EXACT  2
  +
   /*
   **  ____ Private Part of the API ___________________________
   */
  @@ -339,7 +342,7 @@
   char   *MM_error(void);
   
   /* Standard Malloc-Style API */
  -MM     *mm_create(size_t size, const char *file);
  +MM     *mm_create(size_t size, const char *file, int flag);
   int     mm_permission(MM *mm, mode_t mode, uid_t owner, gid_t group);
   void    mm_destroy(MM *mm);
   int     mm_lock(MM *mm, mm_lock_mode mode);
  
  
  
  1.7       +5 -1      apr/shmem/unix/mm/mm_alloc.c
  
  Index: mm_alloc.c
  ===================================================================
  RCS file: /home/cvs/apr/shmem/unix/mm/mm_alloc.c,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- mm_alloc.c	2000/05/03 17:15:49	1.6
  +++ mm_alloc.c	2000/12/02 07:08:06	1.7
  @@ -50,7 +50,7 @@
   /*
    * Create a memory pool
    */
  -MM *mm_create(size_t usize, const char *file)
  +MM *mm_create(size_t usize, const char *file, int flag)
   {
       MM *mm = NULL;
       void *core;
  @@ -65,6 +65,10 @@
           usize = maxsize;
       if (usize < MM_ALLOC_MINSIZE)
           usize = MM_ALLOC_MINSIZE;
  +
  +    if (flag & MM_ALLOCATE_ENOUGH) {
  +        usize += sizeof(*mm);
  +    }
   
       /* determine size */
       size = usize+SIZEOF_mem_pool;
  
  
  
  1.5       +1 -1      apr/shmem/unix/mm/mm_global.c
  
  Index: mm_global.c
  ===================================================================
  RCS file: /home/cvs/apr/shmem/unix/mm/mm_global.c,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- mm_global.c	2000/05/03 17:15:49	1.4
  +++ mm_global.c	2000/12/02 07:08:07	1.5
  @@ -53,7 +53,7 @@
   {
       if (mm_global != NULL)
           return FALSE;
  -    if ((mm_global = mm_create(size, file)) == NULL)
  +    if ((mm_global = mm_create(size, file, MM_ALLOCATE_EXACT)) == NULL)
           return FALSE;
       return TRUE;
   }
  
  
  
  1.4       +1 -1      apr/shmem/unix/mm/mm_test.c
  
  Index: mm_test.c
  ===================================================================
  RCS file: /home/cvs/apr/shmem/unix/mm/mm_test.c,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- mm_test.c	2000/05/03 17:15:49	1.3
  +++ mm_test.c	2000/12/02 07:08:07	1.4
  @@ -197,7 +197,7 @@
       size = mm_maxsize();
       if (size > 1024*1024*1)
           size = 1024*1024*1;
  -    mm = mm_create(size, NULL);
  +    mm = mm_create(size, NULL, MM_ALLOCATE_EXACT);
       FAILED_IF(mm == NULL)
       mm_display_info(mm);
       s = mm_available(mm);
  
  
  
  1.23      +1 -1      apache-2.0/src/modules/mpm/dexter/scoreboard.c
  
  Index: scoreboard.c
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/modules/mpm/dexter/scoreboard.c,v
  retrieving revision 1.22
  retrieving revision 1.23
  diff -u -r1.22 -r1.23
  --- scoreboard.c	2000/11/10 21:51:08	1.22
  +++ scoreboard.c	2000/12/02 07:08:08	1.23
  @@ -102,7 +102,7 @@
       const char *fname;
   
       fname = ap_server_root_relative(p, ap_scoreboard_fname);
  -    if (apr_shm_init(&scoreboard_shm, SCOREBOARD_SIZE + 80, fname, p) != APR_SUCCESS)
{
  +    if (apr_shm_init(&scoreboard_shm, SCOREBOARD_SIZE, fname, p) != APR_SUCCESS) {
           apr_snprintf(buf, sizeof(buf), "%s: could not open(create) scoreboard",
                       ap_server_argv0);
           perror(buf);
  
  
  
  1.43      +13 -2     apache-2.0/src/modules/mpm/mpmt_pthread/scoreboard.c
  
  Index: scoreboard.c
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/modules/mpm/mpmt_pthread/scoreboard.c,v
  retrieving revision 1.42
  retrieving revision 1.43
  diff -u -r1.42 -r1.43
  --- scoreboard.c	2000/11/10 21:51:09	1.42
  +++ scoreboard.c	2000/12/02 07:08:09	1.43
  @@ -89,12 +89,16 @@
   #include "apr_shmem.h"
   
   static apr_shmem_t *scoreboard_shm = NULL;
  +static apr_shmem_t *status_shm = NULL;
   
   apr_status_t ap_cleanup_shared_mem(void *d)
   {
       apr_shm_free(scoreboard_shm, ap_scoreboard_image);
  +    apr_shm_free(status_shm, ap_new_scoreboard_image);
       ap_scoreboard_image = NULL;
  +    ap_new_scoreboard_image = NULL;
       apr_shm_destroy(scoreboard_shm);
  +    apr_shm_destroy(status_shm);
   
       return APR_SUCCESS;
   }
  @@ -105,19 +109,26 @@
       const char *fname;
   
       fname = ap_server_root_relative(p, ap_scoreboard_fname);
  -    if (apr_shm_init(&scoreboard_shm, SCOREBOARD_SIZE + NEW_SCOREBOARD_SIZE + 80, fname,
p) != APR_SUCCESS) {
  +    if (apr_shm_init(&scoreboard_shm, SCOREBOARD_SIZE, fname, p) != APR_SUCCESS) {
           apr_snprintf(buf, sizeof(buf), "%s: could not open(create) scoreboard",
                       ap_server_argv0);
           perror(buf);
           exit(APEXIT_INIT);
       }
       ap_scoreboard_image = apr_shm_malloc(scoreboard_shm, SCOREBOARD_SIZE);
  -    ap_new_scoreboard_image = apr_shm_malloc(scoreboard_shm, NEW_SCOREBOARD_SIZE);
  +    if (apr_shm_init(&status_shm, NEW_SCOREBOARD_SIZE, fname, p) != APR_SUCCESS) {
  +        apr_snprintf(buf, sizeof(buf), "%s: could not open(create) scoreboard",
  +                    ap_server_argv0);
  +        perror(buf);
  +        exit(APEXIT_INIT);
  +    }
  +    ap_new_scoreboard_image = apr_shm_malloc(status_shm, NEW_SCOREBOARD_SIZE);
       if (ap_scoreboard_image == NULL || ap_new_scoreboard_image == NULL) {
           apr_snprintf(buf, sizeof(buf), "%s: cannot allocate scoreboard",
                       ap_server_argv0);
           perror(buf);
           apr_shm_destroy(scoreboard_shm);
  +        apr_shm_destroy(status_shm);
           exit(APEXIT_INIT);
       }
       apr_register_cleanup(p, NULL, ap_cleanup_shared_mem, apr_null_cleanup);
  
  
  
  1.5       +1 -1      apache-2.0/src/modules/mpm/perchild/scoreboard.c
  
  Index: scoreboard.c
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/modules/mpm/perchild/scoreboard.c,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- scoreboard.c	2000/11/10 21:51:10	1.4
  +++ scoreboard.c	2000/12/02 07:08:11	1.5
  @@ -102,7 +102,7 @@
       const char *fname;
   
       fname = ap_server_root_relative(p, ap_scoreboard_fname);
  -    if (apr_shm_init(&scoreboard_shm, SCOREBOARD_SIZE + 80, fname, p) != APR_SUCCESS)
{
  +    if (apr_shm_init(&scoreboard_shm, SCOREBOARD_SIZE, fname, p) != APR_SUCCESS) {
           apr_snprintf(buf, sizeof(buf), "%s: could not open(create) scoreboard",
                       ap_server_argv0);
           perror(buf);
  
  
  
  1.138     +16 -5     apache-2.0/src/modules/mpm/prefork/prefork.c
  
  Index: prefork.c
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/modules/mpm/prefork/prefork.c,v
  retrieving revision 1.137
  retrieving revision 1.138
  diff -u -r1.137 -r1.138
  --- prefork.c	2000/12/01 17:41:26	1.137
  +++ prefork.c	2000/12/02 07:08:12	1.138
  @@ -321,12 +321,16 @@
   #include "apr_shmem.h"
   
   static apr_shmem_t *scoreboard_shm = NULL;
  +static apr_shmem_t *status_shm = NULL;
   
   static apr_status_t cleanup_shared_mem(void *d)
   {
       apr_shm_free(scoreboard_shm, ap_scoreboard_image);
  +    apr_shm_free(status_shm, ap_new_scoreboard_image);
       ap_scoreboard_image = NULL;
  +    ap_new_scoreboard_image = NULL;
       apr_shm_destroy(scoreboard_shm);
  +    apr_shm_destroy(status_shm);
       return APR_SUCCESS;
   }
   
  @@ -336,20 +340,27 @@
       const char *fname;
   
       fname = ap_server_root_relative(p, ap_scoreboard_fname);
  -    if (apr_shm_init(&scoreboard_shm, SCOREBOARD_SIZE + NEW_SCOREBOARD_SIZE + 80, fname,
p) != APR_SUCCESS) {
  +    if (apr_shm_init(&scoreboard_shm, SCOREBOARD_SIZE, fname, p) != APR_SUCCESS) {
   	apr_snprintf(buf, sizeof(buf), "%s: could not open(create) scoreboard",
   		    ap_server_argv0);
   	perror(buf);
   	exit(APEXIT_INIT);
       }
       ap_scoreboard_image = apr_shm_malloc(scoreboard_shm, SCOREBOARD_SIZE); 
  -    ap_new_scoreboard_image = apr_shm_malloc(scoreboard_shm, NEW_SCOREBOARD_SIZE); 
  -    if (ap_scoreboard_image == NULL) {
  -	apr_snprintf(buf, sizeof(buf), "%s: cannot allocate scoreboard",
  +    if (apr_shm_init(&status_shm, NEW_SCOREBOARD_SIZE, fname, p) != APR_SUCCESS) {
  +	apr_snprintf(buf, sizeof(buf), "%s: could not open(create) scoreboard",
   		    ap_server_argv0);
   	perror(buf);
  -	apr_shm_destroy(scoreboard_shm);
   	exit(APEXIT_INIT);
  +    }
  +    ap_new_scoreboard_image = apr_shm_malloc(status_shm, NEW_SCOREBOARD_SIZE); 
  +    if (ap_scoreboard_image == NULL || ap_new_scoreboard_image == NULL) {
  +	apr_snprintf(buf, sizeof(buf), "%s: cannot allocate scoreboard",
  +		    ap_server_argv0);
  +	perror(buf);
  +        apr_shm_destroy(scoreboard_shm);
  +        apr_shm_destroy(status_shm);
  +        exit(APEXIT_INIT);
       }
       apr_register_cleanup(p, NULL, cleanup_shared_mem, apr_null_cleanup);
       ap_scoreboard_image->global.running_generation = 0;
  
  
  

Mime
View raw message