From 5628a41223252b3878074ab06f4f17b498a8fc51 Mon Sep 17 00:00:00 2001 From: Aaron Bannert Date: Fri, 1 Feb 2002 17:22:57 +0000 Subject: [PATCH] Create the scoreboard (in the parent) in a global pool context, so it survives graceful restarts. This fixes a SEGV during graceful restarts. Children who attach to this scoreboard keep the same pool as before (pchild) since they should detach/unmap when the child process exits. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@93159 13f79535-47bb-0310-9956-ffa450edef68 --- server/scoreboard.c | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/server/scoreboard.c b/server/scoreboard.c index 81a2ed6e17..57d2be444f 100644 --- a/server/scoreboard.c +++ b/server/scoreboard.c @@ -165,14 +165,27 @@ void ap_init_scoreboard(void *shared_score) * a scoreboard shared between processes using any IPC technique, * not just a shared memory segment */ -static apr_status_t open_scoreboard(apr_pool_t *p) +static apr_status_t open_scoreboard(apr_pool_t *pconf) { #if APR_HAS_SHARED_MEMORY apr_status_t rv; char *fname = NULL; + apr_pool_t *global_pool; + + /* We don't want to have to recreate the scoreboard after + * restarts, so we'll create a global pool and never clean it. + */ + rv = apr_pool_create(&global_pool, NULL); + if (rv != APR_SUCCESS) { + ap_log_error(APLOG_MARK, APLOG_CRIT, rv, NULL, + "Fatal error: unable to create global pool " + "for use with by the scoreboard"); + return rv; + } #ifndef WIN32 - rv = apr_shm_create(&ap_scoreboard_shm, scoreboard_size, fname, p); + rv = apr_shm_create(&ap_scoreboard_shm, scoreboard_size, fname, + global_pool); if ((rv != APR_SUCCESS) && (rv != APR_ENOTIMPL)) { ap_log_error(APLOG_MARK, APLOG_CRIT, rv, NULL, "Fatal error: could not create scoreboard " @@ -184,9 +197,13 @@ static apr_status_t open_scoreboard(apr_pool_t *p) { #endif if (ap_scoreboard_fname) { - fname = ap_server_root_relative(p, ap_scoreboard_fname); + fname = ap_server_root_relative(global_pool, ap_scoreboard_fname); + /* make sure the file doesn't exist before trying + * to create the segment. */ + apr_file_remove(fname, global_pool); } - rv = apr_shm_create(&ap_scoreboard_shm, scoreboard_size, fname, p); + rv = apr_shm_create(&ap_scoreboard_shm, scoreboard_size, fname, + global_pool); if (rv != APR_SUCCESS) { ap_log_error(APLOG_MARK, APLOG_CRIT, rv, NULL, "Fatal error: could not open(create) scoreboard"); -- 2.40.0