From 4a0447cf13a138e6185eecc5609e4c5a27a75fdf Mon Sep 17 00:00:00 2001 From: Cliff Woolley Date: Tue, 30 Apr 2002 06:48:45 +0000 Subject: [PATCH] SHMCB should not have been using apr_rmm -- it was doing so incorrectly, for one thing. But it just plain doesn't need it. Rip it out to avoid segfaulting. Submitted by: Aaron Bannert git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@94876 13f79535-47bb-0310-9956-ffa450edef68 --- CHANGES | 2 ++ modules/ssl/ssl_scache_shmcb.c | 57 ++++------------------------------ 2 files changed, 8 insertions(+), 51 deletions(-) diff --git a/CHANGES b/CHANGES index c6c8b31250..dafa3e5d7e 100644 --- a/CHANGES +++ b/CHANGES @@ -1,5 +1,7 @@ Changes with Apache 2.0.37 + *) Fixed SHMCB session caching. [Aaron Bannert, Cliff Woolley] + *) Synced with remaining changes from mod_ssl 2.8.8-1.3.24: - Avoid SIGBUS on sparc machines with SHMCB session caches - Allow whitespace between the pipe and the name of the diff --git a/modules/ssl/ssl_scache_shmcb.c b/modules/ssl/ssl_scache_shmcb.c index 6bcb6fbe8c..fe74577197 100644 --- a/modules/ssl/ssl_scache_shmcb.c +++ b/modules/ssl/ssl_scache_shmcb.c @@ -357,17 +357,11 @@ static void shmcb_set_safe_time_ex(unsigned char *dest, ** */ -static void *shmcb_malloc(SSLModConfigRec *mc, size_t size) -{ - apr_rmm_off_t off = apr_rmm_malloc(mc->pSessionCacheDataRMM, size); - return apr_rmm_addr_get(mc->pSessionCacheDataRMM, off); -} - void ssl_scache_shmcb_init(server_rec *s, apr_pool_t *p) { SSLModConfigRec *mc = myModConfig(s); - void *shm_segment = NULL; - int avail, avail_orig; + void *shm_segment; + apr_size_t shm_segsize; apr_status_t rv; /* @@ -388,46 +382,12 @@ void ssl_scache_shmcb_init(server_rec *s, apr_pool_t *p) apr_strerror(rv, buf, sizeof(buf))); ssl_die(); } + shm_segment = apr_shm_baseaddr_get(mc->pSessionCacheDataMM); + shm_segsize = apr_shm_size_get(mc->pSessionCacheDataMM); - if ((rv = apr_rmm_init(&(mc->pSessionCacheDataRMM), NULL, - apr_shm_baseaddr_get(mc->pSessionCacheDataMM), - mc->nSessionCacheDataSize, - mc->pPool)) != APR_SUCCESS) { - char buf[100]; - ssl_log(s, SSL_LOG_ERROR, - "Cannot initialize rmm: (%d)%s", rv, - apr_strerror(rv, buf, sizeof(buf))); - ssl_die(); - } - - /* - * Create cache inside the shared memory segment - */ - avail_orig = avail = mc->nSessionCacheDataSize - apr_rmm_overhead_get(0); - ssl_log(s, SSL_LOG_TRACE, "Shared-memory segment has %u available", - avail); - - /* - * For some reason to do with MM's internal management, I can't - * allocate the full amount. Implement a reasonable form of trial - * and error and output trace information. - */ - while ((shm_segment == NULL) && ((avail_orig - avail) * 100 < avail_orig)) { - shm_segment = shmcb_malloc(mc, avail); - if (shm_segment == NULL) { - ssl_log(s, SSL_LOG_TRACE, - "shmcb_malloc attempt for %u bytes failed", avail); - avail -= 4; - } - } - if (shm_segment == NULL) { - ssl_log(s, SSL_LOG_ERROR, - "Cannot allocate memory for the 'shmcb' session cache\n"); - ssl_die(); - } ssl_log(s, SSL_LOG_TRACE, "shmcb_init allocated %u bytes of shared " - "memory", avail); - if (!shmcb_init_memory(s, shm_segment, avail)) { + "memory", shm_segsize); + if (!shmcb_init_memory(s, shm_segment, shm_segsize)) { ssl_log(s, SSL_LOG_ERROR, "Failure initialising 'shmcb' shared memory"); ssl_die(); @@ -447,11 +407,6 @@ void ssl_scache_shmcb_kill(server_rec *s) { SSLModConfigRec *mc = myModConfig(s); - if (mc->pSessionCacheDataRMM != NULL) { - apr_rmm_destroy(mc->pSessionCacheDataRMM); - mc->pSessionCacheDataRMM = NULL; - } - if (mc->pSessionCacheDataMM != NULL) { apr_shm_destroy(mc->pSessionCacheDataMM); mc->pSessionCacheDataMM = NULL; -- 2.40.0