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
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);
#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;
}
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);
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);
#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;
}
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;
}