Skip to content

Commit

Permalink
Use anonymous shared memory segments here
Browse files Browse the repository at this point in the history
  • Loading branch information
hummeltech committed Mar 24, 2024
1 parent 2ce51df commit a50a92f
Showing 1 changed file with 6 additions and 20 deletions.
26 changes: 6 additions & 20 deletions src/mod_tile.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,6 @@ APLOG_USE_MODULE(tile);

apr_shm_t *stats_shm;
apr_shm_t *delaypool_shm;
char *shmfilename;
char *shmfilename_delaypool;
apr_global_mutex_t *stats_mutex;
apr_global_mutex_t *delay_mutex;

Expand Down Expand Up @@ -1716,37 +1714,25 @@ static int mod_tile_post_config(apr_pool_t *pconf, apr_pool_t *plog,
return OK;
} /* Kilroy was here */

/* Create the shared memory segment */

/*
* Create a unique filename using our pid. This information is
* stashed in the global variable so the children inherit it.
* TODO get the location from the environment $TMPDIR or somesuch.
*/
shmfilename = apr_psprintf(pconf, "/tmp/httpd_shm.%ld", (long int)getpid());
shmfilename_delaypool = apr_psprintf(pconf, "/tmp/httpd_shm_delay.%ld", (long int)getpid());

/* Now create that segment
/* Create the shared memory segment
* would prefer to use scfg->configs->nelts here but that does
* not seem to be set at this stage, so rely on previously set layerCount */

rs = apr_shm_create(&stats_shm, sizeof(stats_data) + layerCount * 2 * sizeof(apr_uint64_t),
(const char *) shmfilename, pconf);
NULL, pconf);

if (rs != APR_SUCCESS) {
ap_log_error(APLOG_MARK, APLOG_ERR, rs, s,
"Failed to create shared memory segment on file %s",
shmfilename);
"Failed to create 'stats' shared memory segment");
return HTTP_INTERNAL_SERVER_ERROR;
}

rs = apr_shm_create(&delaypool_shm, sizeof(delaypool),
(const char *) shmfilename_delaypool, pconf);
NULL, pconf);

if (rs != APR_SUCCESS) {
ap_log_error(APLOG_MARK, APLOG_ERR, rs, s,
"Failed to create shared memory segment on file %s",
shmfilename_delaypool);
"Failed to create 'delaypool' shared memory segment");
return HTTP_INTERNAL_SERVER_ERROR;
}

Expand Down Expand Up @@ -1897,7 +1883,7 @@ static void mod_tile_child_init(apr_pool_t *p, server_rec *s)
if (rs != APR_SUCCESS) {
ap_log_error(APLOG_MARK, APLOG_CRIT, rs, s,
"Failed to reopen mutex on file %s",
shmfilename);
mutexfilename);
/* There's really nothing else we can do here, since
* This routine doesn't return a status. */
exit(1); /* Ugly, but what else? */
Expand Down

0 comments on commit a50a92f

Please sign in to comment.