httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From yla...@apache.org
Subject svn commit: r1601864 - /httpd/httpd/trunk/modules/filters/mod_sed.c
Date Wed, 11 Jun 2014 11:47:27 GMT
Author: ylavic
Date: Wed Jun 11 11:47:26 2014
New Revision: 1601864

URL: http://svn.apache.org/r1601864
Log:
mod_sed:
Avoid the call to APR_BUCKET_REMOVE() + apr_bucket_delete() on the
same bucket.
Also, empty the input brigade while looping to avoid the trailing
apr_brigade_cleanup() call (no functional change).

Modified:
    httpd/httpd/trunk/modules/filters/mod_sed.c

Modified: httpd/httpd/trunk/modules/filters/mod_sed.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/filters/mod_sed.c?rev=1601864&r1=1601863&r2=1601864&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/filters/mod_sed.c (original)
+++ httpd/httpd/trunk/modules/filters/mod_sed.c Wed Jun 11 11:47:26 2014
@@ -317,11 +317,9 @@ static apr_status_t sed_response_filter(
      * in sed's internal buffer which can't be flushed until new line
      * character is arrived.
      */
-    for (b = APR_BRIGADE_FIRST(bb); b != APR_BRIGADE_SENTINEL(bb);) {
-        const char *buf = NULL;
-        apr_size_t bytes = 0;
+    while (!APR_BRIGADE_EMPTY(bb)) {
+        b = APR_BRIGADE_FIRST(bb);
         if (APR_BUCKET_IS_EOS(b)) {
-            apr_bucket *b1 = APR_BUCKET_NEXT(b);
             /* Now clean up the internal sed buffer */
             sed_finalize_eval(&ctx->eval, ctx);
             status = flush_output_buffer(ctx);
@@ -329,44 +327,37 @@ static apr_status_t sed_response_filter(
                 clear_ctxpool(ctx);
                 return status;
             }
+            /* Move the eos bucket to ctx->bb brigade */
             APR_BUCKET_REMOVE(b);
-            /* Insert the eos bucket to ctx->bb brigade */
             APR_BRIGADE_INSERT_TAIL(ctx->bb, b);
-            b = b1;
         }
         else if (APR_BUCKET_IS_FLUSH(b)) {
-            apr_bucket *b1 = APR_BUCKET_NEXT(b);
-            APR_BUCKET_REMOVE(b);
             status = flush_output_buffer(ctx);
             if (status != APR_SUCCESS) {
                 clear_ctxpool(ctx);
                 return status;
             }
+            /* Move the flush bucket to ctx->bb brigade */
+            APR_BUCKET_REMOVE(b);
             APR_BRIGADE_INSERT_TAIL(ctx->bb, b);
-            b = b1;
-        }
-        else if (APR_BUCKET_IS_METADATA(b)) {
-            b = APR_BUCKET_NEXT(b);
         }
-        else if (apr_bucket_read(b, &buf, &bytes, APR_BLOCK_READ)
-                 == APR_SUCCESS) {
-            apr_bucket *b1 = APR_BUCKET_NEXT(b);
-            status = sed_eval_buffer(&ctx->eval, buf, bytes, ctx);
-            if (status != APR_SUCCESS) {
-                clear_ctxpool(ctx);
-                return status;
+        else {
+            if (!APR_BUCKET_IS_METADATA(b)) {
+                const char *buf = NULL;
+                apr_size_t bytes = 0;
+
+                status = apr_bucket_read(b, &buf, &bytes, APR_BLOCK_READ);
+                if (status == APR_SUCCESS) {
+                    status = sed_eval_buffer(&ctx->eval, buf, bytes, ctx);
+                }
+                if (status != APR_SUCCESS) {
+                    clear_ctxpool(ctx);
+                    return status;
+                }
             }
-            APR_BUCKET_REMOVE(b);
             apr_bucket_delete(b);
-            b = b1;
-        }
-        else {
-            apr_bucket *b1 = APR_BUCKET_NEXT(b);
-            APR_BUCKET_REMOVE(b);
-            b = b1;
         }
     }
-    apr_brigade_cleanup(bb);
     status = flush_output_buffer(ctx);
     if (status != APR_SUCCESS) {
         clear_ctxpool(ctx);



Mime
View raw message