MCPcopy Create free account
hub / github.com/apache/httpd / initialize_tables

Function initialize_tables

modules/aaa/mod_auth_digest.c:263–365  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

261#if APR_HAS_SHARED_MEMORY
262
263static int initialize_tables(server_rec *s, apr_pool_t *ctx)
264{
265 unsigned long idx;
266 apr_status_t sts;
267
268 /* set up client list */
269
270 /* Create the shared memory segment */
271
272 client_shm = NULL;
273 client_rmm = NULL;
274 client_lock = NULL;
275 opaque_lock = NULL;
276 client_list = NULL;
277
278 /*
279 * Create a unique filename using our pid. This information is
280 * stashed in the global variable so the children inherit it.
281 */
282 client_shm_filename = ap_runtime_dir_relative(ctx, "authdigest_shm");
283 client_shm_filename = ap_append_pid(ctx, client_shm_filename, ".");
284
285 /* Use anonymous shm by default, fall back on name-based. */
286 sts = apr_shm_create(&client_shm, shmem_size, NULL, ctx);
287 if (APR_STATUS_IS_ENOTIMPL(sts)) {
288 /* For a name-based segment, remove it first in case of a
289 * previous unclean shutdown. */
290 apr_shm_remove(client_shm_filename, ctx);
291
292 /* Now create that segment */
293 sts = apr_shm_create(&client_shm, shmem_size,
294 client_shm_filename, ctx);
295 }
296
297 if (APR_SUCCESS != sts) {
298 ap_log_error(APLOG_MARK, APLOG_ERR, sts, s, APLOGNO(01762)
299 "Failed to create shared memory segment on file %s",
300 client_shm_filename);
301 log_error_and_cleanup("failed to initialize shm", sts, s);
302 return HTTP_INTERNAL_SERVER_ERROR;
303 }
304
305 sts = apr_rmm_init(&client_rmm,
306 NULL, /* no lock, we'll do the locking ourselves */
307 apr_shm_baseaddr_get(client_shm),
308 shmem_size, ctx);
309 if (sts != APR_SUCCESS) {
310 log_error_and_cleanup("failed to initialize rmm", sts, s);
311 return !OK;
312 }
313
314 client_list = rmm_malloc(client_rmm, sizeof(*client_list) +
315 sizeof(client_entry *) * num_buckets);
316 if (!client_list) {
317 log_error_and_cleanup("failed to allocate shared memory", -1, s);
318 return !OK;
319 }
320 client_list->table = (client_entry**) (client_list + 1);

Callers 1

initialize_moduleFunction · 0.85

Calls 6

ap_runtime_dir_relativeFunction · 0.85
ap_append_pidFunction · 0.85
log_error_and_cleanupFunction · 0.85
rmm_mallocFunction · 0.85
ap_global_mutex_createFunction · 0.85
ap_log_errorFunction · 0.50

Tested by

no test coverage detected