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

Function mxcfg_lookup

server/util_mutex.c:319–372  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

317}
318
319static mutex_cfg_t *mxcfg_lookup(apr_pool_t *p, const char *type)
320{
321 mutex_cfg_t *defcfg, *mxcfg, *newcfg;
322
323 defcfg = apr_hash_get(mxcfg_by_type, "default", APR_HASH_KEY_STRING);
324
325 /* MUST exist in table, or wasn't registered */
326 mxcfg = apr_hash_get(mxcfg_by_type, type, APR_HASH_KEY_STRING);
327 if (!mxcfg) {
328 return NULL;
329 }
330
331 /* order of precedence:
332 * 1. Mutex directive for this mutex
333 * 2. Mutex directive for "default"
334 * 3. Defaults for this mutex from ap_mutex_register()
335 * 4. Global defaults
336 */
337
338 if (mxcfg->set) {
339 newcfg = mxcfg;
340 }
341 else if (defcfg->set) {
342 newcfg = defcfg;
343 }
344 else if (mxcfg->none || mxcfg->mech != APR_LOCK_DEFAULT) {
345 newcfg = mxcfg;
346 }
347 else {
348 newcfg = defcfg;
349 }
350
351 if (!newcfg->none && mutex_needs_file(newcfg->mech) && !newcfg->dir) {
352 /* a file-based mutex mechanism was configured, but
353 * without a mutex file directory; go back through
354 * the chain to find the directory, store in new
355 * mutex cfg structure
356 */
357 newcfg = apr_pmemdup(p, newcfg, sizeof *newcfg);
358
359 /* !true if dir not already set: mxcfg->set && defcfg->dir */
360 if (defcfg->set && defcfg->dir) {
361 newcfg->dir = defcfg->dir;
362 }
363 else if (mxcfg->dir) {
364 newcfg->dir = mxcfg->dir;
365 }
366 else {
367 newcfg->dir = defcfg->dir;
368 }
369 }
370
371 return newcfg;
372}
373
374static void log_bad_create_options(server_rec *s, const char *type)
375{

Callers 3

ap_global_mutex_createFunction · 0.85
ap_proc_mutex_createFunction · 0.85
ap_dump_mutexesFunction · 0.85

Calls 1

mutex_needs_fileFunction · 0.85

Tested by

no test coverage detected