You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by do...@postman.hyperreal.org on 1998/08/26 22:01:28 UTC
cvs commit: apache-1.3/src/main http_core.c http_main.c
dougm 98/08/26 13:01:26
Modified: src CHANGES
src/include http_core.h
src/main http_core.c http_main.c
Log:
new `GprofDir' directive when compiled with -DGPROF, where gprof can
plop gmon.out profile data for each child
Submitted by: Doug MacEachern
Reviewed by: Dean Gaudet
Revision Changes Path
1.1037 +3 -0 apache-1.3/src/CHANGES
Index: CHANGES
===================================================================
RCS file: /export/home/cvs/apache-1.3/src/CHANGES,v
retrieving revision 1.1036
retrieving revision 1.1037
diff -u -r1.1036 -r1.1037
--- CHANGES 1998/08/25 10:51:49 1.1036
+++ CHANGES 1998/08/26 20:01:19 1.1037
@@ -1,5 +1,8 @@
Changes with Apache 1.3.2
+ *) new `GprofDir' directive when compiled with -DGPROF, where gprof can
+ plop gmon.out profile data for each child [Doug MacEachern]
+
*) Use the construct ``"$@"'' instead of ``$*'' in the generated
config.status script to be immune against arguments with whitespaces.
[Yves Arrouye <yv...@apple.com>] PR#2866
1.48 +4 -0 apache-1.3/src/include/http_core.h
Index: http_core.h
===================================================================
RCS file: /export/home/cvs/apache-1.3/src/include/http_core.h,v
retrieving revision 1.47
retrieving revision 1.48
diff -u -r1.47 -r1.48
--- http_core.h 1998/08/10 04:16:13 1.47
+++ http_core.h 1998/08/26 20:01:21 1.48
@@ -253,6 +253,10 @@
typedef struct {
+#ifdef GPROF
+ char *gprof_dir;
+#endif
+
/* Name translations --- we want the core to be able to do *something*
* so it's at least a minimally functional web server on its own (and
* can be tested that way). But let's keep it to the bare minimum:
1.225 +24 -0 apache-1.3/src/main/http_core.c
Index: http_core.c
===================================================================
RCS file: /export/home/cvs/apache-1.3/src/main/http_core.c,v
retrieving revision 1.224
retrieving revision 1.225
diff -u -r1.224 -r1.225
--- http_core.c 1998/08/11 15:37:52 1.224
+++ http_core.c 1998/08/26 20:01:22 1.225
@@ -271,6 +271,9 @@
int is_virtual = s->is_virtual;
conf = (core_server_config *)ap_pcalloc(a, sizeof(core_server_config));
+#ifdef GPROF
+ conf->gprof_dir = NULL;
+#endif
conf->access_name = is_virtual ? NULL : DEFAULT_ACCESS_FNAME;
conf->ap_document_root = is_virtual ? NULL : DOCUMENT_LOCATION;
conf->sec = ap_make_array(a, 40, sizeof(void *));
@@ -793,6 +796,23 @@
return NULL;
}
+#ifdef GPROF
+static const char *set_gprof_dir(cmd_parms *cmd, void *dummy, char *arg)
+{
+ void *sconf = cmd->server->module_config;
+ core_server_config *conf = ap_get_module_config(sconf, &core_module);
+
+ const char *err = ap_check_cmd_context(cmd,
+ NOT_IN_DIR_LOC_FILE|NOT_IN_LIMIT);
+ if (err != NULL) {
+ return err;
+ }
+
+ conf->gprof_dir = ap_pstrdup(cmd->pool, arg);
+ return NULL;
+}
+#endif /*GPROF*/
+
static const char *set_document_root(cmd_parms *cmd, void *dummy, char *arg)
{
void *sconf = cmd->server->module_config;
@@ -2458,6 +2478,10 @@
"Selects which authenticated users or groups may access a protected space" },
{ "Satisfy", satisfy, NULL, OR_AUTHCFG, TAKE1,
"access policy if both allow and require used ('all' or 'any')" },
+#ifdef GPROF
+{ "GprofDir", set_gprof_dir, NULL, RSRC_CONF, TAKE1,
+ "Directory to plop gmon.out files" },
+#endif
/* Old resource config file commands */
1.388 +37 -0 apache-1.3/src/main/http_main.c
Index: http_main.c
===================================================================
RCS file: /export/home/cvs/apache-1.3/src/main/http_main.c,v
retrieving revision 1.387
retrieving revision 1.388
diff -u -r1.387 -r1.388
--- http_main.c 1998/08/13 01:55:06 1.387
+++ http_main.c 1998/08/26 20:01:22 1.388
@@ -414,6 +414,42 @@
static APACHE_TLS int volatile exit_after_unblock = 0;
+#ifdef GPROF
+/*
+ * change directory for gprof to plop the gmon.out file
+ * configure in httpd.conf:
+ * GprofDir logs/ -> $ServerRoot/logs/gmon.out
+ * GprofDir logs/% -> $ServerRoot/logs/gprof.$pid/gmon.out
+ */
+static void chdir_for_gprof()
+{
+ core_server_config *sconf =
+ ap_get_module_config(server_conf->module_config, &core_module);
+ char *dir = sconf->gprof_dir;
+
+ if(dir) {
+ char buf[512];
+ int len = strlen(sconf->gprof_dir) - 1;
+ if(*(dir + len) == '%') {
+ dir[len] = '\0';
+ ap_snprintf(buf, sizeof(buf), "%sgprof.%d", dir, (int)getpid());
+ }
+ dir = ap_server_root_relative(pconf, buf[0] ? buf : dir);
+ if(mkdir(dir, 0755) < 0 && errno != EEXIST) {
+ ap_log_error(APLOG_MARK, APLOG_ERR, server_conf,
+ "gprof: error creating directory %s", dir);
+ }
+ }
+ else {
+ dir = ap_server_root_relative(pconf, "logs");
+ }
+
+ chdir(dir);
+}
+#else
+#define chdir_for_gprof()
+#endif
+
/* a clean exit from a child with proper cleanup */
static void __attribute__((noreturn)) clean_child_exit(int code)
{
@@ -421,6 +457,7 @@
ap_child_exit_modules(pchild, server_conf);
ap_destroy_pool(pchild);
}
+ chdir_for_gprof();
exit(code);
}