a small head start for debugging crashes... usefulness changes with platform and build options...

Index: src/modules/experimental/mod_whatkilledus.c
===================================================================
RCS file: /home/cvs/apache-1.3/src/modules/experimental/mod_whatkilledus.c,v
retrieving revision 1.1
diff -u -r1.1 mod_whatkilledus.c
--- src/modules/experimental/mod_whatkilledus.c 20 Feb 2004 11:41:05 -0000      1.1
+++ src/modules/experimental/mod_whatkilledus.c 7 May 2004 12:26:38 -0000
@@ -75,8 +75,10 @@
  * client connections
  */
 static char *log_fname;
+static conn_rec *active_connection;
 static char *local_addr;
 static char *remote_addr;
+static request_rec *active_request;
 static char *request_plus_headers;
 static char buffer[2048];
 
@@ -121,10 +123,11 @@
                           msg_prefix, ei->sig);
     write(logfd, buffer, msg_len);
 
-    if (local_addr) {
+    if (active_connection) {
         msg_len = ap_snprintf(buffer, sizeof buffer,
-                              "%s active connection: %s->%s\n",
-                              msg_prefix, remote_addr, local_addr);
+                              "%s active connection: %s->%s (conn_rec %pp)\n",
+                              msg_prefix, remote_addr, local_addr,
+                              active_connection);
     }
     else {
         msg_len = ap_snprintf(buffer, sizeof buffer,
@@ -134,10 +137,11 @@
 
     write(logfd, buffer, msg_len);
 
-    if (request_plus_headers) {
+    if (active_request) {
         msg_len = ap_snprintf(buffer, sizeof buffer,
-                              "%s active request:\n",
-                              msg_prefix);
+                              "%s active request (request_rec %pp):\n",
+                              msg_prefix,
+                              active_request);
         write(logfd, buffer, msg_len);
         write(logfd, request_plus_headers, strlen(request_plus_headers));
     }
@@ -170,12 +174,14 @@
 
 static void clear_conn_info(void *ignored)
 {
+    active_connection = NULL;
     local_addr = remote_addr = NULL;
 }
 
 static void save_conn_info(request_rec *r)
 {
     conn_rec *c = r->connection;
+    active_connection = r->connection;
     local_addr =  ap_psprintf(c->pool, "%pI", &c->local_addr);
     remote_addr = ap_psprintf(c->pool, "%pI", &c->remote_addr);
 
@@ -184,6 +190,7 @@
 
 static void clear_req_info(void *ignored)
 {
+    active_request = NULL;
     request_plus_headers = NULL;
 }
 
@@ -261,6 +268,9 @@
      */
     int len = strlen(r->the_request);
     char *ch;
+
+    active_request = r;
+
     ap_table_do(count_headers, &len, r->headers_in, NULL);
 
     request_plus_headers = ap_palloc(r->pool, len + 2 /* 2 for the '\n' + '\0' at end 
*/);
@@ -286,7 +296,7 @@
     /* save whatever info, like client, which vhost, which port
      * (to know SSL or not), etc.
      */
-    if (!local_addr) { /* first request on this connection */
+    if (!active_connection) { /* first request on this connection */
         save_conn_info(r);
     }
 

Reply via email to