From bcb88ba28acfe272977e9d913fc2b12e5f2b07be Mon Sep 17 00:00:00 2001 From: Doug MacEachern Date: Thu, 29 Nov 2001 04:06:05 +0000 Subject: [PATCH] carry over from 1.3: disable profiling in the parent process #ifdef GPROF PR: Obtained from: Submitted by: Reviewed by: git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@92230 13f79535-47bb-0310-9956-ffa450edef68 --- include/ap_mpm.h | 14 ++++++++++++++ server/main.c | 2 ++ server/mpm/prefork/prefork.c | 5 +++++ 3 files changed, 21 insertions(+) diff --git a/include/ap_mpm.h b/include/ap_mpm.h index 96c24a8904..bf16e9f982 100644 --- a/include/ap_mpm.h +++ b/include/ap_mpm.h @@ -183,4 +183,18 @@ AP_DECLARE(apr_status_t) ap_os_create_privileged_process( */ AP_DECLARE(apr_status_t) ap_mpm_query(int query_code, int *result); +/* Defining GPROF when compiling uses the moncontrol() function to + * disable gprof profiling in the parent, and enable it only for + * request processing in children (or in one_process mode). It's + * absolutely required to get useful gprof results under linux + * because the profile itimers and such are disabled across a + * fork(). It's probably useful elsewhere as well. + */ +#ifdef GPROF +extern void moncontrol(int); +#define AP_MONCONTROL(x) moncontrol(x) +#else +#define AP_MONCONTROL(x) +#endif + #endif diff --git a/server/main.c b/server/main.c index 7bbee310d7..677ef0bb73 100644 --- a/server/main.c +++ b/server/main.c @@ -298,6 +298,8 @@ int main(int argc, const char * const argv[]) module **mod; const char *optarg; + AP_MONCONTROL(0); /* turn of profiling of startup */ + apr_initialize(); process = create_process(argc, argv); diff --git a/server/mpm/prefork/prefork.c b/server/mpm/prefork/prefork.c index cba8eb7e00..6bba1ef20c 100644 --- a/server/mpm/prefork/prefork.c +++ b/server/mpm/prefork/prefork.c @@ -759,6 +759,7 @@ static int make_child(server_rec *s, int slot) } #endif RAISE_SIGSTOP(MAKE_CHILD); + AP_MONCONTROL(1); /* Disable the parent's signal handlers and set up proper handling in * the child. */ @@ -970,6 +971,10 @@ int ap_mpm_run(apr_pool_t *_pconf, apr_pool_t *plog, server_rec *s) set_signals(); + if (one_process) { + AP_MONCONTROL(1); + } + if (ap_daemons_max_free < ap_daemons_min_free + 1) /* Don't thrash... */ ap_daemons_max_free = ap_daemons_min_free + 1; -- 2.40.0