This really should be a post_config hook, but the error log is already * redirected by that point, so we need to do this in the open_logs phase. */
| 1218 | * redirected by that point, so we need to do this in the open_logs phase. |
| 1219 | */ |
| 1220 | static int prefork_open_logs(apr_pool_t *p, apr_pool_t *plog, apr_pool_t *ptemp, server_rec *s) |
| 1221 | { |
| 1222 | int startup = 0; |
| 1223 | int level_flags = 0; |
| 1224 | ap_listen_rec **listen_buckets; |
| 1225 | apr_status_t rv; |
| 1226 | char id[16]; |
| 1227 | int i; |
| 1228 | |
| 1229 | pconf = p; |
| 1230 | |
| 1231 | /* the reverse of pre_config, we want this only the first time around */ |
| 1232 | if (retained->mpm->module_loads == 1) { |
| 1233 | startup = 1; |
| 1234 | level_flags |= APLOG_STARTUP; |
| 1235 | } |
| 1236 | |
| 1237 | if ((num_listensocks = ap_setup_listeners(ap_server_conf)) < 1) { |
| 1238 | ap_log_error(APLOG_MARK, APLOG_ALERT | level_flags, 0, |
| 1239 | (startup ? NULL : s), |
| 1240 | "no listening sockets available, shutting down"); |
| 1241 | return !OK; |
| 1242 | } |
| 1243 | |
| 1244 | if (one_process) { |
| 1245 | retained->mpm->num_buckets = 1; |
| 1246 | } |
| 1247 | else if (!retained->mpm->was_graceful) { |
| 1248 | /* Preserve the number of buckets on graceful restarts. */ |
| 1249 | retained->mpm->num_buckets = 0; |
| 1250 | } |
| 1251 | if ((rv = ap_duplicate_listeners(pconf, ap_server_conf, |
| 1252 | &listen_buckets, &retained->mpm->num_buckets))) { |
| 1253 | ap_log_error(APLOG_MARK, APLOG_CRIT | level_flags, rv, |
| 1254 | (startup ? NULL : s), |
| 1255 | "could not duplicate listeners"); |
| 1256 | return !OK; |
| 1257 | } |
| 1258 | all_buckets = apr_pcalloc(pconf, retained->mpm->num_buckets * |
| 1259 | sizeof(prefork_child_bucket)); |
| 1260 | for (i = 0; i < retained->mpm->num_buckets; i++) { |
| 1261 | if ((rv = ap_mpm_pod_open(pconf, &all_buckets[i].pod))) { |
| 1262 | ap_log_error(APLOG_MARK, APLOG_CRIT | level_flags, rv, |
| 1263 | (startup ? NULL : s), |
| 1264 | "could not open pipe-of-death"); |
| 1265 | return !OK; |
| 1266 | } |
| 1267 | /* Initialize cross-process accept lock (safe accept needed only) */ |
| 1268 | if ((rv = SAFE_ACCEPT((apr_snprintf(id, sizeof id, "%i", i), |
| 1269 | ap_proc_mutex_create(&all_buckets[i].mutex, |
| 1270 | NULL, AP_ACCEPT_MUTEX_TYPE, |
| 1271 | id, s, pconf, 0))))) { |
| 1272 | ap_log_error(APLOG_MARK, APLOG_CRIT | level_flags, rv, |
| 1273 | (startup ? NULL : s), |
| 1274 | "could not create accept mutex"); |
| 1275 | return !OK; |
| 1276 | } |
| 1277 | all_buckets[i].listeners = listen_buckets[i]; |
nothing calls this directly
no test coverage detected