| 162 | } |
| 163 | |
| 164 | AP_DECLARE_NONSTD(const char *)ap_set_mutex(cmd_parms *cmd, void *dummy, |
| 165 | const char *arg) |
| 166 | { |
| 167 | apr_pool_t *p = cmd->pool; |
| 168 | apr_pool_t *ptemp = cmd->temp_pool; |
| 169 | const char **elt; |
| 170 | const char *mechdir; |
| 171 | int no_mutex = 0, omit_pid = 0; |
| 172 | apr_array_header_t *type_list; |
| 173 | apr_lockmech_e mech; |
| 174 | apr_status_t rv; |
| 175 | const char *mutexdir; |
| 176 | mutex_cfg_t *mxcfg; |
| 177 | const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY); |
| 178 | |
| 179 | if (err != NULL) { |
| 180 | return err; |
| 181 | } |
| 182 | |
| 183 | mechdir = ap_getword_conf(cmd->pool, &arg); |
| 184 | if (*mechdir == '\0') { |
| 185 | return "Mutex requires at least a mechanism argument (" |
| 186 | AP_ALL_AVAILABLE_MUTEXES_STRING ")"; |
| 187 | } |
| 188 | |
| 189 | rv = ap_parse_mutex(mechdir, p, &mech, &mutexdir); |
| 190 | if (rv == APR_ENOTIMPL) { |
| 191 | return apr_pstrcat(p, "Invalid Mutex argument ", mechdir, |
| 192 | " (" AP_ALL_AVAILABLE_MUTEXES_STRING ")", NULL); |
| 193 | } |
| 194 | else if (rv == APR_BADARG |
| 195 | || (mutexdir && !ap_is_directory(ptemp, mutexdir))) { |
| 196 | return apr_pstrcat(p, "Invalid Mutex directory in argument ", |
| 197 | mechdir, NULL); |
| 198 | } |
| 199 | else if (rv == APR_ENOLOCK) { /* "none" */ |
| 200 | no_mutex = 1; |
| 201 | } |
| 202 | |
| 203 | /* "OmitPID" can appear at the end of the list, so build a list of |
| 204 | * mutex type names while looking for "OmitPID" (anywhere) or the end |
| 205 | */ |
| 206 | type_list = apr_array_make(cmd->pool, 4, sizeof(const char *)); |
| 207 | while (*arg) { |
| 208 | const char *s = ap_getword_conf(cmd->pool, &arg); |
| 209 | |
| 210 | if (!strcasecmp(s, "omitpid")) { |
| 211 | omit_pid = 1; |
| 212 | } |
| 213 | else { |
| 214 | const char **new_type = (const char **)apr_array_push(type_list); |
| 215 | *new_type = s; |
| 216 | } |
| 217 | } |
| 218 | |
| 219 | if (apr_is_empty_array(type_list)) { /* no mutex type? assume "default" */ |
| 220 | const char **new_type = (const char **)apr_array_push(type_list); |
| 221 | *new_type = "default"; |
nothing calls this directly
no test coverage detected