Received: (from majordom@localhost) by hyperreal.org (8.8.5/8.8.5) id NAA00328; Sun, 3 Aug 1997 13:29:26 -0700 (PDT) Received: (from marc@localhost) by hyperreal.org (8.8.5/8.8.5) id NAA00320 for apache-cvs; Sun, 3 Aug 1997 13:29:23 -0700 (PDT) Date: Sun, 3 Aug 1997 13:29:23 -0700 (PDT) From: Marc Slemko Message-Id: <199708032029.NAA00320@hyperreal.org> To: apache-cvs@hyperreal.org Subject: cvs commit: apache/src http_conf_globals.h http_config.c http_core.c http_main.c Sender: apache-cvs-owner@apache.org Precedence: bulk Reply-To: new-httpd@apache.org marc 97/08/03 13:29:22 Modified: htdocs/manual/mod core.html directives.html src http_conf_globals.h http_config.c http_core.c http_main.c Log: Add a CoreDumpDirectory directive to allow users to specify where Apache should try to core dump. Reviewed by: Brian Behlendorf, Dean Gaudet Revision Changes Path 1.69 +15 -0 apache/htdocs/manual/mod/core.html Index: core.html =================================================================== RCS file: /export/home/cvs/apache/htdocs/manual/mod/core.html,v retrieving revision 1.68 retrieving revision 1.69 diff -u -r1.68 -r1.69 --- core.html 1997/07/30 18:41:46 1.68 +++ core.html 1997/08/03 20:29:15 1.69 @@ -29,6 +29,7 @@
  • AuthType
  • BindAddress
  • ClearModuleList +
  • CoreDumpDirectory
  • DefaultType
  • <Directory>
  • <DirectoryMatch> @@ -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 AddModule directive.


    + +

    CoreDumpDirectory directive

    + +Syntax: CoreDumpDirectory directory
    +Default: the same location as ServerRoot
    +Context: server config
    +Status: core

    + +This controls the directory to which Apache attempts to switch before +dumping core. The default is in the ServerRoot +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.


    DefaultType directive

    1.29 +1 -0 apache/htdocs/manual/mod/directives.html Index: directives.html =================================================================== RCS file: /export/home/cvs/apache/htdocs/manual/mod/directives.html,v retrieving revision 1.28 retrieving revision 1.29 diff -u -r1.28 -r1.29 --- directives.html 1997/07/30 20:08:16 1.28 +++ directives.html 1997/08/03 20:29:16 1.29 @@ -73,6 +73,7 @@
  • CookieLog (mod_cookies)
  • CookieLog (mod_log_config)
  • CookieTracking +
  • CoreDumpDirectory
  • CustomLog
  • DefaultIcon
  • DefaultType 1.16 +5 -0 apache/src/http_conf_globals.h Index: http_conf_globals.h =================================================================== RCS file: /export/home/cvs/apache/src/http_conf_globals.h,v retrieving revision 1.15 retrieving revision 1.16 diff -u -r1.15 -r1.16 --- http_conf_globals.h 1997/07/27 02:15:45 1.15 +++ http_conf_globals.h 1997/08/03 20:29:18 1.16 @@ -87,3 +87,8 @@ extern char server_root[MAX_STRING_LEN]; extern char server_confname[MAX_STRING_LEN]; +/* We want this to have the least chance of being correupted if there + * is some memory corruption, so we allocate it statically. + */ +extern char coredump_dir[MAX_STRING_LEN]; + 1.69 +2 -0 apache/src/http_config.c Index: http_config.c =================================================================== RCS file: /export/home/cvs/apache/src/http_config.c,v retrieving revision 1.68 retrieving revision 1.69 diff -u -r1.68 -r1.69 --- http_config.c 1997/07/28 18:22:42 1.68 +++ http_config.c 1997/08/03 20:29:18 1.69 @@ -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) 1.104 +14 -0 apache/src/http_core.c Index: http_core.c =================================================================== RCS file: /export/home/cvs/apache/src/http_core.c,v retrieving revision 1.103 retrieving revision 1.104 diff -u -r1.103 -r1.104 --- http_core.c 1997/07/31 07:51:34 1.103 +++ http_core.c 1997/08/03 20:29:19 1.104 @@ -1242,6 +1242,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 "; + 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 */ @@ -1366,6 +1379,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 }, }; 1.194 +7 -16 apache/src/http_main.c Index: http_main.c =================================================================== RCS file: /export/home/cvs/apache/src/http_main.c,v retrieving revision 1.193 retrieving revision 1.194 diff -u -r1.193 -r1.194 --- http_main.c 1997/08/02 06:49:32 1.193 +++ http_main.c 1997/08/03 20:29:20 1.194 @@ -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... */ @@ -1463,15 +1464,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); } @@ -1479,15 +1475,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); }