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

Function ap_parse_mutex

server/util_mutex.c:49–127  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

47#define APLOG_MODULE_INDEX AP_CORE_MODULE_INDEX
48
49AP_DECLARE(apr_status_t) ap_parse_mutex(const char *arg, apr_pool_t *pool,
50 apr_lockmech_e *mutexmech,
51 const char **mutexfile)
52{
53 /* Split arg into meth and file */
54 char *meth = apr_pstrdup(pool, arg);
55 char *file = strchr(meth, ':');
56 if (file) {
57 *(file++) = '\0';
58 if (!*file) {
59 file = NULL;
60 }
61 }
62
63 /* APR determines temporary filename unless overridden below,
64 * we presume file indicates an mutexfile is a file path
65 * unless the method sets mutexfile=file and NULLs file
66 */
67 *mutexfile = NULL;
68
69 if (!strcasecmp(meth, "none") || !strcasecmp(meth, "no")) {
70 return APR_ENOLOCK;
71 }
72
73 /* NOTE: previously, 'yes' implied 'sem' */
74 if (!strcasecmp(meth, "default") || !strcasecmp(meth, "yes")) {
75 *mutexmech = APR_LOCK_DEFAULT;
76 }
77#if APR_HAS_FCNTL_SERIALIZE
78 else if (!strcasecmp(meth, "fcntl") || !strcasecmp(meth, "file")) {
79 *mutexmech = APR_LOCK_FCNTL;
80 }
81#endif
82#if APR_HAS_FLOCK_SERIALIZE
83 else if (!strcasecmp(meth, "flock") || !strcasecmp(meth, "file")) {
84 *mutexmech = APR_LOCK_FLOCK;
85 }
86#endif
87#if APR_HAS_POSIXSEM_SERIALIZE
88 else if (!strcasecmp(meth, "posixsem") || !strcasecmp(meth, "sem")) {
89 *mutexmech = APR_LOCK_POSIXSEM;
90 /* Posix/SysV semaphores aren't file based, use the literal name
91 * if provided and fall back on APR's default if not. Today, APR
92 * will ignore it, but once supported it has an absurdly short limit.
93 */
94 if (file) {
95 *mutexfile = apr_pstrdup(pool, file);
96
97 file = NULL;
98 }
99 }
100#endif
101#if APR_HAS_SYSVSEM_SERIALIZE
102 else if (!strcasecmp(meth, "sysvsem") || !strcasecmp(meth, "sem")) {
103 *mutexmech = APR_LOCK_SYSVSEM;
104 }
105#endif
106#if APR_HAS_PROC_PTHREAD_SERIALIZE

Callers 1

ap_set_mutexFunction · 0.85

Calls 1

ap_server_root_relativeFunction · 0.85

Tested by

no test coverage detected