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 @@
   <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; -->
  
  
  
  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 @@
   <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>
  
  
  
  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 <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
    */
  @@ -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);
   }
  
  
  

Reply via email to