You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by ji...@apache.org on 2013/03/11 17:33:22 UTC

svn commit: r1455221 - in /httpd/httpd/branches/2.4.x: ./ STATUS modules/filters/mod_charset_lite.c

Author: jim
Date: Mon Mar 11 16:33:22 2013
New Revision: 1455221

URL: http://svn.apache.org/r1455221
Log:
Merge r1429582 from trunk:

According to my testing, one special case of 'log_xlate_error', i.e. EES_INCOMPLETE_CHAR,
 is 13x (!!!) faster with the use 'ap_bin2hex' instead of apr_snprintf(..., "%02X" + srlen for each character.

Output is *not* exactly the same. It was uppercase, now it is lowercase.
It is just for logging, so I don't think it is an issue.
Should it be, a call to ap_strtoupper can be added.

So sad it is just for logging in case of error... no real speedup to be expected in real life .

Submitted by: jailletc36
Reviewed/backported by: jim

Modified:
    httpd/httpd/branches/2.4.x/   (props changed)
    httpd/httpd/branches/2.4.x/STATUS
    httpd/httpd/branches/2.4.x/modules/filters/mod_charset_lite.c

Propchange: httpd/httpd/branches/2.4.x/
------------------------------------------------------------------------------
  Merged /httpd/httpd/trunk:r1429582

Modified: httpd/httpd/branches/2.4.x/STATUS
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.4.x/STATUS?rev=1455221&r1=1455220&r2=1455221&view=diff
==============================================================================
--- httpd/httpd/branches/2.4.x/STATUS (original)
+++ httpd/httpd/branches/2.4.x/STATUS Mon Mar 11 16:33:22 2013
@@ -117,12 +117,6 @@ PATCHES ACCEPTED TO BACKPORT FROM TRUNK:
     2.4.x cumulative patch: http://people.apache.org/~jailletc36/backport5.patch (minus CHANGES for 1448171)
     +1: jailletc36, igalic, jim
 
-  * mod_charset_lite: clean up and speed up special case of logging function by x13 using ap_bin2hex intoduced in 2.4.4
-    It will be in lowercase instead of uppercase, but it is only for logging. I don't think this is a real issue.
-    trunk patch: http://svn.apache.org/viewvc?view=revision&revision=1429582
-    2.4.x patch: trunk patch applies.
-    +1: jailletc36, humbedooh, jim
-    
   * mod_log_forensic: Speed up logging of characters that need to be escaped. PR 50919
     trunk patch: http://svn.apache.org/viewvc?view=revision&revision=1429564
     2.4.x patch: trunk patch applies.

Modified: httpd/httpd/branches/2.4.x/modules/filters/mod_charset_lite.c
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.4.x/modules/filters/mod_charset_lite.c?rev=1455221&r1=1455220&r2=1455221&view=diff
==============================================================================
--- httpd/httpd/branches/2.4.x/modules/filters/mod_charset_lite.c (original)
+++ httpd/httpd/branches/2.4.x/modules/filters/mod_charset_lite.c Mon Mar 11 16:33:22 2013
@@ -474,7 +474,7 @@ static void log_xlate_error(ap_filter_t 
     charset_filter_ctx_t *ctx = f->ctx;
     const char *msg;
     char msgbuf[100];
-    int cur;
+    int len;
 
     switch(ctx->ees) {
     case EES_LIMIT:
@@ -492,12 +492,14 @@ static void log_xlate_error(ap_filter_t 
     case EES_INCOMPLETE_CHAR:
         rv = 0;
         strcpy(msgbuf, APLOGNO(02196) "xlate filter - incomplete char at end of input - ");
-        cur = 0;
-        while ((apr_size_t)cur < ctx->saved) {
-            apr_snprintf(msgbuf + strlen(msgbuf), sizeof(msgbuf) - strlen(msgbuf),
-                         "%02X", (unsigned)ctx->buf[cur]);
-            ++cur;
-        }
+        len = ctx->saved;
+
+        /* We must ensure not to process more than what would fit in the
+         * remaining of the destination buffer, including terminating NULL */
+        if (len > (sizeof(msgbuf) - strlen(msgbuf) - 1) / 2)
+            len = (sizeof(msgbuf) - strlen(msgbuf) - 1) / 2;
+
+        ap_bin2hex(ctx->buf, len, msgbuf + strlen(msgbuf));
         msg = msgbuf;
         break;
     case EES_DOWNSTREAM: