diff options
author | Ryan Bloom <rbb@apache.org> | 2000-12-02 08:08:12 +0100 |
---|---|---|
committer | Ryan Bloom <rbb@apache.org> | 2000-12-02 08:08:12 +0100 |
commit | b7e17bb7995fdd588ff8fec71d05402a40120763 (patch) | |
tree | 1c95f542884df7b131969478dfed4e851268b55f /server/mpm/prefork/prefork.c | |
parent | Remove an unnecessary header file. (diff) | |
download | apache2-b7e17bb7995fdd588ff8fec71d05402a40120763.tar.xz apache2-b7e17bb7995fdd588ff8fec71d05402a40120763.zip |
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.
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@87153 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to '')
-rw-r--r-- | server/mpm/prefork/prefork.c | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/server/mpm/prefork/prefork.c b/server/mpm/prefork/prefork.c index 0ee89c94f1..2e92927ab7 100644 --- a/server/mpm/prefork/prefork.c +++ b/server/mpm/prefork/prefork.c @@ -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; } |