]> granicus.if.org Git - apache/commitdiff
MPMs that require multiple segments of shared memory now just use two
authorRyan Bloom <rbb@apache.org>
Sat, 2 Dec 2000 07:08:12 +0000 (07:08 +0000)
committerRyan Bloom <rbb@apache.org>
Sat, 2 Dec 2000 07:08:12 +0000 (07:08 +0000)
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.

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@87153 13f79535-47bb-0310-9956-ffa450edef68

server/mpm/dexter/scoreboard.c
server/mpm/mpmt_pthread/scoreboard.c
server/mpm/perchild/scoreboard.c
server/mpm/prefork/prefork.c

index d640741684efd8896fbb90cdfb594b759b6b7c89..3bf4869a6432e739552e3cf899c6cdaffdd69c12 100644 (file)
@@ -102,7 +102,7 @@ static void setup_shared_mem(apr_pool_t *p)
     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);
index 9692d9bc6642d45e949ca3fde758fb36c5d66a73..a2c190504993dc535a878b428260237f4baedaec 100644 (file)
@@ -89,12 +89,16 @@ static int maintain_connection_status = 1;
 #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 @@ static void setup_shared_mem(apr_pool_t *p)
     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);
index a956eda0e6efc61d9fe6e4d470de9d01aa006bd1..10b0730ad425aca90182efe3ce944b7cc712c833 100644 (file)
@@ -102,7 +102,7 @@ static void setup_shared_mem(apr_pool_t *p)
     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);
index 0ee89c94f1628946ae9d490b6be2a51f9470c383..2e92927ab7bd0f24f25002d243e1e1e8807de39d 100644 (file)
@@ -321,12 +321,16 @@ static void accept_mutex_off(void)
 #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,21 +340,28 @@ static void setup_shared_mem(apr_pool_t *p)
     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;
 }