httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jim Jagielski <...@jaguNET.com>
Subject Re: Proposal: Increase request in worker_score
Date Tue, 30 Oct 2007 19:12:17 GMT

On Oct 22, 2007, at 9:39 AM, Jim Jagielski wrote:

>
> The other option, of course, would be to keep the small
> buffer but have some some sort of config directive that
> indicates whether you want the 1st or last 64 bytes :)
> That seems a nice stop-gap for 2.2
>

FWIW, last night I hacked up a quick little way to do
this... If conceptually OK, I'll add doccos. This is
for trunk but really designed to be the 2.2 stopgap :)

Index: server/scoreboard.c
===================================================================
--- server/scoreboard.c (revision 590167)
+++ server/scoreboard.c (working copy)
@@ -40,6 +40,7 @@
AP_DECLARE_DATA scoreboard *ap_scoreboard_image = NULL;
AP_DECLARE_DATA const char *ap_scoreboard_fname = NULL;
AP_DECLARE_DATA int ap_extended_status = 0;
+AP_DECLARE_DATA int ap_mod_status_reqtail = 0;
#if APR_HAS_SHARED_MEMORY
@@ -388,6 +389,54 @@
      (*new_sbh)->thread_num = thread_num;
}
+static void copy_request(char *rbuf, apr_size_t rbuflen, request_rec  
*r)
+{
+    apr_size_t slen;
+
+    if (r->the_request == NULL) {
+        apr_cpystrn(rbuf, "NULL", rbuflen);
+    }
+    else if (r->parsed_uri.password == NULL) {
+        if (!ap_mod_status_reqtail) {
+            apr_cpystrn(rbuf, r->the_request, rbuflen);
+        }
+        else {
+            slen = strlen(r->the_request);
+            if (slen < rbuflen) {
+                /* it all fits anyway */
+                apr_cpystrn(rbuf, r->the_request, rbuflen);
+            }
+            else {
+                apr_cpystrn(rbuf, r->the_request+(slen-rbuflen+1),
+                            rbuflen);
+            }
+        }
+    }
+    else {
+        char *p;
+        /* Don't reveal the password in the server-status view */
+        p = apr_pstrcat(r->pool, r->method, " ",
+                        apr_uri_unparse(r->pool, &r->parsed_uri,
+                        APR_URI_UNP_OMITPASSWORD),
+                        r->assbackwards ? NULL : " ", r->protocol,  
NULL);
+        if (!ap_mod_status_reqtail) {
+            apr_cpystrn(rbuf, p, rbuflen);
+        }
+        else {
+            slen = strlen(p);
+            if (slen < rbuflen) {
+                /* it all fits anyway */
+                apr_cpystrn(rbuf, p, rbuflen);
+            }
+            else {
+                apr_cpystrn(rbuf, p+(slen-rbuflen+1), rbuflen);
+            }
+
+        }
+    }
+
+}
+
AP_DECLARE(int) ap_update_child_status_from_indexes(int child_num,
                                                      int thread_num,
                                                      int status,
@@ -430,18 +479,7 @@
              conn_rec *c = r->connection;
              apr_cpystrn(ws->client, ap_get_remote_host(c, r- 
 >per_dir_config,
                          REMOTE_NOLOOKUP, NULL), sizeof(ws->client));
-            if (r->the_request == NULL) {
-                apr_cpystrn(ws->request, "NULL", sizeof(ws->request));
-            } else if (r->parsed_uri.password == NULL) {
-                apr_cpystrn(ws->request, r->the_request, sizeof(ws- 
 >request));
-            } else {
-                /* Don't reveal the password in the server-status  
view */
-                apr_cpystrn(ws->request, apr_pstrcat(r->pool, r- 
 >method, " ",
-                            apr_uri_unparse(r->pool, &r->parsed_uri,
-                            APR_URI_UNP_OMITPASSWORD),
-                            r->assbackwards ? NULL : " ", r- 
 >protocol, NULL),
-                            sizeof(ws->request));
-            }
+            copy_request(ws->request, sizeof(ws->request), r);
              apr_cpystrn(ws->vhost, r->server->server_hostname,
                          sizeof(ws->vhost));
          }
Index: modules/generators/mod_status.c
===================================================================
--- modules/generators/mod_status.c     (revision 590167)
+++ modules/generators/mod_status.c     (working copy)
@@ -128,10 +128,24 @@
      return NULL;
}
+static const char *set_reqtail(cmd_parms *cmd, void *dummy, int arg)
+{
+    const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
+    if (err != NULL) {
+        return err;
+    }
+    ap_mod_status_reqtail = arg;
+    return NULL;
+}
+
+
static const command_rec status_module_cmds[] =
{
      AP_INIT_FLAG("ExtendedStatus", set_extended_status, NULL,  
RSRC_CONF,
        "\"On\" to enable extended status information, \"Off\" to  
disable"),
+    AP_INIT_FLAG("SeeRequestTail", set_reqtail, NULL, RSRC_CONF,
+      "For verbose requests, \"On\" to see the last 64 chars of the  
request, "
+      "\"Off\" to see the front 64"),
      {NULL}
};
Index: include/ap_mmn.h
===================================================================
--- include/ap_mmn.h    (revision 590167)
+++ include/ap_mmn.h    (working copy)
@@ -136,6 +136,7 @@
   * 20071023.0 (2.3.0-dev)  add ap_get_scoreboard(sbh) split from  
the less
   *                         conventional ap_get_scoreboard(proc,  
thread)
   * 20071023.1 (2.3.0-dev)  Add flags field to struct proxy_alias
+ * 20071023.2 (2.3.0-dev)  Add ap_mod_status_reqtail
   */
#define MODULE_MAGIC_COOKIE 0x41503234UL /* "AP24" */
@@ -143,7 +144,7 @@
#ifndef MODULE_MAGIC_NUMBER_MAJOR
#define MODULE_MAGIC_NUMBER_MAJOR 20071023
#endif
-#define MODULE_MAGIC_NUMBER_MINOR 1                    /* 0...n */
+#define MODULE_MAGIC_NUMBER_MINOR 2                    /* 0...n */
/**
   * Determine if the server's current MODULE_MAGIC_NUMBER is at least a
Index: include/scoreboard.h
===================================================================
--- include/scoreboard.h        (revision 590167)
+++ include/scoreboard.h        (working copy)
@@ -188,6 +188,7 @@
AP_DECLARE_DATA extern scoreboard *ap_scoreboard_image;
AP_DECLARE_DATA extern const char *ap_scoreboard_fname;
AP_DECLARE_DATA extern int ap_extended_status;
+AP_DECLARE_DATA extern int ap_mod_status_reqtail;
AP_DECLARE_DATA extern ap_generation_t volatile ap_my_generation;


Mime
View raw message