Return-Path: Delivered-To: apmail-httpd-cvs-archive@www.apache.org Received: (qmail 78834 invoked from network); 17 Apr 2008 14:10:06 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 17 Apr 2008 14:10:06 -0000 Received: (qmail 40449 invoked by uid 500); 17 Apr 2008 14:10:07 -0000 Delivered-To: apmail-httpd-cvs-archive@httpd.apache.org Received: (qmail 40270 invoked by uid 500); 17 Apr 2008 14:10:06 -0000 Mailing-List: contact cvs-help@httpd.apache.org; run by ezmlm Precedence: bulk Reply-To: dev@httpd.apache.org list-help: list-unsubscribe: List-Post: List-Id: Delivered-To: mailing list cvs@httpd.apache.org Received: (qmail 40259 invoked by uid 99); 17 Apr 2008 14:10:06 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 17 Apr 2008 07:10:06 -0700 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 17 Apr 2008 14:09:31 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 034A11A9832; Thu, 17 Apr 2008 07:09:44 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r649118 - in /httpd/httpd/branches/2.2.x: CHANGES STATUS docs/manual/mod/mod_substitute.xml modules/filters/mod_substitute.c Date: Thu, 17 Apr 2008 14:09:36 -0000 To: cvs@httpd.apache.org From: jim@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20080417140944.034A11A9832@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: jim Date: Thu Apr 17 07:09:29 2008 New Revision: 649118 URL: http://svn.apache.org/viewvc?rev=649118&view=rev Log: Merge r627764, r628864 from trunk: Change default of mod_substitute to flattening... Via current discussion on dev@httpd In the case where we have only 1 pattern, then we can safely be quick, no matter what. Reviewed by: jim Modified: httpd/httpd/branches/2.2.x/CHANGES httpd/httpd/branches/2.2.x/STATUS httpd/httpd/branches/2.2.x/docs/manual/mod/mod_substitute.xml httpd/httpd/branches/2.2.x/modules/filters/mod_substitute.c Modified: httpd/httpd/branches/2.2.x/CHANGES URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.2.x/CHANGES?rev=649118&r1=649117&r2=649118&view=diff ============================================================================== --- httpd/httpd/branches/2.2.x/CHANGES [utf-8] (original) +++ httpd/httpd/branches/2.2.x/CHANGES [utf-8] Thu Apr 17 07:09:29 2008 @@ -1,6 +1,11 @@ -*- coding: utf-8 -*- Changes with Apache 2.2.9 + *) mod_substitute: The default is now flattening the buckets after + each substitution. The newly added 'q' flag allows for the + quicker, more efficient bucket-splitting if the user so + desires. [Jim Jagielski] + *) http_filters: Don't spin if get an error when reading the next chunk. PR 44381 [Ruediger Pluem] Modified: httpd/httpd/branches/2.2.x/STATUS URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.2.x/STATUS?rev=649118&r1=649117&r2=649118&view=diff ============================================================================== --- httpd/httpd/branches/2.2.x/STATUS (original) +++ httpd/httpd/branches/2.2.x/STATUS Thu Apr 17 07:09:29 2008 @@ -88,15 +88,6 @@ PATCHES ACCEPTED TO BACKPORT FROM TRUNK: [ start all new proposals below, under PATCHES PROPOSED. ] - * mod_substitute: Make default behavior flattening of buckets. Allow - for people to specifically set "quick" mode. - Trunk version of patch: - http://svn.apache.org/viewvc?view=rev&revision=627764 - http://svn.apache.org/viewvc?view=rev&revision=628864 - Backport version for 2.2.x of patch: - Trunk version works (minus CHANGES conflict) - +1: jim, covener, wrowe - * mod_speling: remove regression from 1.3/2.0 behavior and drop dependency between mod_speling and AcceptPathInfo. PR: 43562 Modified: httpd/httpd/branches/2.2.x/docs/manual/mod/mod_substitute.xml URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.2.x/docs/manual/mod/mod_substitute.xml?rev=649118&r1=649117&r2=649118&view=diff ============================================================================== --- httpd/httpd/branches/2.2.x/docs/manual/mod/mod_substitute.xml (original) +++ httpd/httpd/branches/2.2.x/docs/manual/mod/mod_substitute.xml Thu Apr 17 07:09:29 2008 @@ -37,7 +37,7 @@ Substitute Pattern to filter the response content -Substitute s/pattern/substitution/[inf] +Substitute s/pattern/substitution/[infq] directory .htaccess FileInfo @@ -59,7 +59,14 @@
f
The f flag causes mod_substitute to flatten the result of a substitution allowing for later substitutions to - take place on the boundary of this one.
+ take place on the boundary of this one. This is the default. +
q
+
The q flag causes mod_substitute to not + flatten the buckets after each substitution. This can + result in much faster response and a decrease in memory + utilization, but should only be used if there is no possibility + that the result of one substitution will ever match a pattern + or regex of a subsequent one.
Example Modified: httpd/httpd/branches/2.2.x/modules/filters/mod_substitute.c URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.2.x/modules/filters/mod_substitute.c?rev=649118&r1=649117&r2=649118&view=diff ============================================================================== --- httpd/httpd/branches/2.2.x/modules/filters/mod_substitute.c (original) +++ httpd/httpd/branches/2.2.x/modules/filters/mod_substitute.c Thu Apr 17 07:09:29 2008 @@ -103,6 +103,7 @@ apr_pool_t *tmp_pool) { int i; + int force_quick = 0; ap_regmatch_t regm[AP_MAX_REG_MATCH]; apr_size_t bytes; apr_size_t len; @@ -128,6 +129,13 @@ apr_pool_create(&tpool, tmp_pool); scratch = NULL; fbytes = 0; + /* + * Simple optimization. If we only have one pattern, then + * we can safely avoid the overhead of flattening + */ + if (cfg->patterns->nelts == 1) { + force_quick = 1; + } for (i = 0; i < cfg->patterns->nelts; i++) { for (b = APR_BRIGADE_FIRST(mybb); b != APR_BRIGADE_SENTINEL(mybb); @@ -147,7 +155,7 @@ { /* get offset into buff for pattern */ len = (apr_size_t) (repl - buff); - if (script->flatten) { + if (script->flatten && !force_quick) { /* * We are flattening the buckets here, meaning * that we don't do the fast bucket splits. @@ -181,7 +189,7 @@ bytes -= len; buff += len; } - if (script->flatten && s1) { + if (script->flatten && s1 && !force_quick) { /* * we've finished looking at the bucket, so remove the * old one and add in our new one @@ -219,7 +227,7 @@ /* first, grab the replacement string */ repl = ap_pregsub(tmp_pool, script->replacement, p, AP_MAX_REG_MATCH, regm); - if (script->flatten) { + if (script->flatten && !force_quick) { SEDSCAT(s1, s2, tmp_pool, p, regm[0].rm_so, repl); } else { @@ -236,7 +244,7 @@ */ p += regm[0].rm_eo; } - if (script->flatten && s1) { + if (script->flatten && s1 && !force_quick) { s1 = apr_pstrcat(tmp_pool, s1, p, NULL); tmp_b = apr_bucket_transient_create(s1, strlen(s1), f->r->connection->bucket_alloc); @@ -488,7 +496,7 @@ subst_pattern_t *nscript; int is_pattern = 0; int ignore_case = 0; - int flatten = 0; + int flatten = 1; ap_regex_t *r = NULL; if (apr_tolower(*line) != 's') { @@ -525,8 +533,10 @@ is_pattern = 1; else if (delim == 'f') flatten = 1; + else if (delim == 'q') + flatten = 0; else - return "Bad Substitute flag, only s///[inf] are supported"; + return "Bad Substitute flag, only s///[infq] are supported"; flags++; }