httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Marc Slemko <ma...@znep.com>
Subject [PATCH] coredumpdir
Date Sun, 27 Jul 1997 20:27:07 GMT
Once again, my CoreDumpDirectory patch.  This time it is updated
to use static memory allocation.

Index: htdocs/manual/mod/core.html
===================================================================
RCS file: /export/home/cvs/apache/htdocs/manual/mod/core.html,v
retrieving revision 1.67
diff -u -r1.67 core.html
--- core.html	1997/07/21 21:26:55	1.67
+++ core.html	1997/07/27 20:22:57
@@ -29,6 +29,7 @@
 <li><A HREF="#authtype">AuthType</A>
 <li><A HREF="#bindaddress">BindAddress</A>
 <li><A HREF="#clearmodulelist">ClearModuleList</A>
+<li><A HREF="#coredumpdirectory">CoreDumpDirectory</A>
 <li><A HREF="#defaulttype">DefaultType</A>
 <li><A HREF="#directory">&lt;Directory&gt;</A>
 <li><A HREF="#directorymatch">&lt;DirectoryMatch&gt;</A>
@@ -264,6 +265,20 @@
 The server comes with a built-in list of active modules.  This
 directive clears the list.  It is assumed that the list will then be
 re-populated using the <A HREF="#addmodule">AddModule</A> directive.<p><hr>
+
+<h2><A name="coredumpdirectory">CoreDumpDirectory directive</A></h2>
+<!--%plaintext &lt;?INDEX {\tt CoreDumpDirectory} directive&gt; -->
+<strong>Syntax:</strong> CoreDumpDirectory <em>directory</em><br>
+<strong>Default:</strong> the same location as ServerRoot<br>
+<strong>Context:</strong> server config<br>
+<strong>Status:</strong> core<p>
+
+This controls the directory to which Apache attempts to switch before
+dumping core.  The default is in the <A HREF="#serverroot">ServerRoot</A>
+directory, however since this should not be writable by the user
+the server runs as, core dumps won't normally get written.  If you
+want a core dump for debugging, you can use this directive to place
+it in a different location.<p><hr>
 
 <h2><A name="defaulttype">DefaultType directive</A></h2>
 <!--%plaintext &lt;?INDEX {\tt DefaultType} directive&gt; -->
Index: htdocs/manual/mod/directives.html
===================================================================
RCS file: /export/home/cvs/apache/htdocs/manual/mod/directives.html,v
retrieving revision 1.27
diff -u -r1.27 directives.html
--- directives.html	1997/07/21 21:26:55	1.27
+++ directives.html	1997/07/27 20:22:57
@@ -72,6 +72,7 @@
 <li><A HREF="mod_cookies.html#cookielog">CookieLog</A> (mod_cookies)
 <li><A HREF="mod_log_config.html#cookielog">CookieLog</A> (mod_log_config)
 <li><A HREF="mod_usertrack.html#cookietracking">CookieTracking</A>
+<li><A HREF="core.html#coredumpdirectory">CoreDumpDirectory</A>
 <li><A HREF="mod_log_config.html#customlog">CustomLog</A>
 <li><A HREF="mod_autoindex.html#defaulticon">DefaultIcon</A>
 <li><A HREF="core.html#defaulttype">DefaultType</A>
Index: src/http_conf_globals.h
===================================================================
RCS file: /export/home/cvs/apache/src/http_conf_globals.h,v
retrieving revision 1.15
diff -u -r1.15 http_conf_globals.h
--- http_conf_globals.h	1997/07/27 02:15:45	1.15
+++ http_conf_globals.h	1997/07/27 20:22:58
@@ -87,3 +87,8 @@
 extern char server_root[MAX_STRING_LEN];
 extern char server_confname[MAX_STRING_LEN];
 
+/* We want this to have the most chance of still being alive if there
+ * is some memory corruption, so we allocte it statically.
+ */
+extern char coredump_dir[MAX_STRING_LEN];
+
Index: src/http_config.c
===================================================================
RCS file: /export/home/cvs/apache/src/http_config.c,v
retrieving revision 1.67
diff -u -r1.67 http_config.c
--- http_config.c	1997/07/27 03:13:30	1.67
+++ http_config.c	1997/07/27 20:23:02
@@ -1154,6 +1154,8 @@
     bind_address.s_addr = htonl(INADDR_ANY);
     listeners = NULL;
     listenbacklog = DEFAULT_LISTENBACKLOG;
+    strncpy(coredump_dir, server_root, sizeof(coredump_dir)-1);
+    coredump_dir[sizeof(coredump_dir)-1] = '\0';
 }
 
 server_rec *init_server_config(pool *p)
Index: src/http_core.c
===================================================================
RCS file: /export/home/cvs/apache/src/http_core.c,v
retrieving revision 1.100
diff -u -r1.100 http_core.c
--- http_core.c	1997/07/24 04:38:09	1.100
+++ http_core.c	1997/07/27 20:23:05
@@ -1196,6 +1196,19 @@
     return NULL;
 }
 
+const char *set_coredumpdir (cmd_parms *cmd, void *dummy, char *arg) {
+    struct stat finfo;
+    if (cmd->server->is_virtual)
+        return "CoreDumpDirectory not allowed in <VirtualHost>";
+    if ((stat(arg, &finfo) == -1) || !S_ISDIR(finfo.st_mode)) {
+	return pstrcat(cmd->pool, "CoreDumpDirectory ", arg, 
+	    " does not exist or is not a directory", NULL);
+    }
+    strncpy(coredump_dir, arg, sizeof(coredump_dir)-1);
+    coredump_dir[sizeof(coredump_dir)-1] = '\0';
+    return NULL;
+}
+
 /* Note --- ErrorDocument will now work from .htaccess files.  
  * The AllowOverride of Fileinfo allows webmasters to turn it off
  */
@@ -1320,6 +1333,7 @@
 { "ThreadsPerChild", set_threads, NULL, RSRC_CONF, TAKE1, "Number of threads a child creates"
},
 { "ExcessRequestsPerChild", set_excess_requests, NULL, RSRC_CONF, TAKE1, "Maximum number
of requests a particular child serves after it is ready to die." },
 { "ListenBacklog", set_listenbacklog, NULL, RSRC_CONF, TAKE1, "maximum length of the queue
of pending connections, as used by listen(2)" },
+{ "CoreDumpDirectory", set_coredumpdir, NULL, RSRC_CONF, TAKE1, "The location of the directory
Apache changes to before dumping core" },
 { NULL },
 };
 
Index: src/http_main.c
===================================================================
RCS file: /export/home/cvs/apache/src/http_main.c,v
retrieving revision 1.187
diff -u -r1.187 http_main.c
--- http_main.c	1997/07/24 04:35:47	1.187
+++ http_main.c	1997/07/27 20:23:12
@@ -193,6 +193,7 @@
 
 char server_root[MAX_STRING_LEN];
 char server_confname[MAX_STRING_LEN];
+char coredump_dir[MAX_STRING_LEN];
 
 /* *Non*-shared http_main globals... */
 
@@ -1444,15 +1445,10 @@
 void bus_error(int sig) {
     char emsg[256];
 
-    ap_snprintf
-	(
-	    emsg,
-	    sizeof(emsg),
-	    "httpd: caught SIGBUS, attempting to dump core in %s",
-	    server_root
-	);
+    ap_snprintf(emsg, sizeof(emsg), 
+        "httpd: caught SIGBUS, attempting to dump core in %s", coredump_dir);
     log_error(emsg, server_conf);
-    chdir(server_root);
+    chdir(coredump_dir);
     abort();         
     exit(1);
 }
@@ -1460,15 +1456,10 @@
 void seg_fault(int sig) {
     char emsg[256];
 
-    ap_snprintf
-	(
-	    emsg,
-	    sizeof(emsg),
-	    "httpd: caught SIGSEGV, attempting to dump core in %s",
-	    server_root
-	);
+    ap_snprintf(emsg, sizeof(emsg), 
+        "httpd: caught SIGSEGV, attempting to dump core in %s", coredump_dir);
     log_error(emsg, server_conf);
-    chdir(server_root);
+    chdir(coredump_dir);
     abort();
     exit(1);
 }


Mime
View raw message