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

Function worker_open_logs

server/mpm/worker/worker.c:1960–2053  ·  view source on GitHub ↗

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. */

Source from the content-addressed store, hash-verified

1958 * redirected by that point, so we need to do this in the open_logs phase.
1959 */
1960static int worker_open_logs(apr_pool_t *p, apr_pool_t *plog, apr_pool_t *ptemp, server_rec *s)
1961{
1962 int startup = 0;
1963 int level_flags = 0;
1964 int num_buckets = 0;
1965 ap_listen_rec **listen_buckets;
1966 apr_status_t rv;
1967 char id[16];
1968 int i;
1969
1970 pconf = p;
1971
1972 /* the reverse of pre_config, we want this only the first time around */
1973 if (retained->mpm->module_loads == 1) {
1974 startup = 1;
1975 level_flags |= APLOG_STARTUP;
1976 }
1977
1978 if ((num_listensocks = ap_setup_listeners(ap_server_conf)) < 1) {
1979 ap_log_error(APLOG_MARK, APLOG_ALERT | level_flags, 0,
1980 (startup ? NULL : s),
1981 "no listening sockets available, shutting down");
1982 return !OK;
1983 }
1984
1985 if (one_process) {
1986 num_buckets = 1;
1987 }
1988 else if (retained->mpm->was_graceful) {
1989 /* Preserve the number of buckets on graceful restarts. */
1990 num_buckets = retained->mpm->num_buckets;
1991 }
1992 if ((rv = ap_duplicate_listeners(pconf, ap_server_conf,
1993 &listen_buckets, &num_buckets))) {
1994 ap_log_error(APLOG_MARK, APLOG_CRIT | level_flags, rv,
1995 (startup ? NULL : s),
1996 "could not duplicate listeners");
1997 return !OK;
1998 }
1999
2000 all_buckets = apr_pcalloc(pconf, num_buckets * sizeof(*all_buckets));
2001 for (i = 0; i < num_buckets; i++) {
2002 if (!one_process && /* no POD in one_process mode */
2003 (rv = ap_mpm_podx_open(pconf, &all_buckets[i].pod))) {
2004 ap_log_error(APLOG_MARK, APLOG_CRIT | level_flags, rv,
2005 (startup ? NULL : s),
2006 "could not open pipe-of-death");
2007 return !OK;
2008 }
2009 /* Initialize cross-process accept lock (safe accept needed only) */
2010 if ((rv = SAFE_ACCEPT((apr_snprintf(id, sizeof id, "%i", i),
2011 ap_proc_mutex_create(&all_buckets[i].mutex,
2012 NULL, AP_ACCEPT_MUTEX_TYPE,
2013 id, s, pconf, 0))))) {
2014 ap_log_error(APLOG_MARK, APLOG_CRIT | level_flags, rv,
2015 (startup ? NULL : s),
2016 "could not create accept mutex");
2017 return !OK;

Callers

nothing calls this directly

Calls 5

ap_setup_listenersFunction · 0.85
ap_duplicate_listenersFunction · 0.85
ap_mpm_podx_openFunction · 0.85
ap_proc_mutex_createFunction · 0.85
ap_log_errorFunction · 0.50

Tested by

no test coverage detected