httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s.@apache.org
Subject svn commit: r956202 - in /httpd/httpd/trunk: include/ap_mmn.h include/httpd.h server/core_filters.c
Date Sat, 19 Jun 2010 09:10:54 GMT
Author: sf
Date: Sat Jun 19 09:10:54 2010
New Revision: 956202

URL: http://svn.apache.org/viewvc?rev=956202&view=rev
Log:
Add deferred write pool to core_output_filter to clean up file descriptors as
soon as the corresponding response has been sent and not only after the
connection has been closed.

This change does not deal with pipelined requests, yet.

Modified:
    httpd/httpd/trunk/include/ap_mmn.h
    httpd/httpd/trunk/include/httpd.h
    httpd/httpd/trunk/server/core_filters.c

Modified: httpd/httpd/trunk/include/ap_mmn.h
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/include/ap_mmn.h?rev=956202&r1=956201&r2=956202&view=diff
==============================================================================
--- httpd/httpd/trunk/include/ap_mmn.h (original)
+++ httpd/httpd/trunk/include/ap_mmn.h Sat Jun 19 09:10:54 2010
@@ -229,6 +229,7 @@
  *                         ap_recent_ctime_ex().
  * 20100609.0 (2.3.6-dev)  Dropped ap_args_to_table due to missing constraints.
  * 20100609.1 (2.3.7-dev)  Introduce ap_log_cserror()
+ * 20100609.2 (2.3.7-dev)  Add deferred write pool to core_output_filter_ctx
  */
 
 #define MODULE_MAGIC_COOKIE 0x41503234UL /* "AP24" */
@@ -236,7 +237,7 @@
 #ifndef MODULE_MAGIC_NUMBER_MAJOR
 #define MODULE_MAGIC_NUMBER_MAJOR 20100609
 #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

Modified: httpd/httpd/trunk/include/httpd.h
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/include/httpd.h?rev=956202&r1=956201&r2=956202&view=diff
==============================================================================
--- httpd/httpd/trunk/include/httpd.h (original)
+++ httpd/httpd/trunk/include/httpd.h Sat Jun 19 09:10:54 2010
@@ -1261,6 +1261,7 @@ typedef struct core_output_filter_ctx {
     apr_size_t bytes_in;
     apr_size_t bytes_written;
     apr_bucket_brigade *tmp_flush_bb;
+    apr_pool_t *deferred_write_pool;
 } core_output_filter_ctx_t;
  
 typedef struct core_filter_ctx {

Modified: httpd/httpd/trunk/server/core_filters.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/core_filters.c?rev=956202&r1=956201&r2=956202&view=diff
==============================================================================
--- httpd/httpd/trunk/server/core_filters.c (original)
+++ httpd/httpd/trunk/server/core_filters.c Sat Jun 19 09:10:54 2010
@@ -383,6 +383,8 @@ apr_status_t ap_core_output_filter(ap_fi
          * allocated from bb->pool which might be wrong.
          */
         ctx->tmp_flush_bb = apr_brigade_create(c->pool, c->bucket_alloc);
+        /* same for buffered_bb and ap_save_brigade */
+        ctx->buffered_bb = apr_brigade_create(c->pool, c->bucket_alloc);
     }
 
     if (new_bb != NULL) {
@@ -512,6 +514,10 @@ apr_status_t ap_core_output_filter(ap_fi
     return APR_SUCCESS;
 }
 
+/*
+ * This function assumes that either ctx->buffered_bb == NULL, or
+ * ctx->buffered_bb is empty, or ctx->buffered_bb == bb
+ */
 static void setaside_remaining_output(ap_filter_t *f,
                                       core_output_filter_ctx_t *ctx,
                                       apr_bucket_brigade *bb,
@@ -524,13 +530,22 @@ static void setaside_remaining_output(ap
     if (!APR_BRIGADE_EMPTY(bb)) {
         c->data_in_output_filters = 1;
         if (bb != ctx->buffered_bb) {
-            /* XXX should this use a separate deferred write pool, like
-             * the original ap_core_output_filter?
-             */
-            ap_save_brigade(f, &(ctx->buffered_bb), &bb, c->pool);
+            if (!ctx->deferred_write_pool) {
+                apr_pool_create(&ctx->deferred_write_pool, c->pool);
+                apr_pool_tag(ctx->deferred_write_pool, "deferred_write");
+            }
+            ap_save_brigade(f, &(ctx->buffered_bb), &bb,
+                            ctx->deferred_write_pool);
             apr_brigade_cleanup(bb);
         }
     }
+    else if (ctx->deferred_write_pool) {
+        /*
+         * There are no more requests in the pipeline. We can just clear the
+         * pool.
+         */
+        apr_pool_clear(ctx->deferred_write_pool);
+    }
 }
 
 #ifndef APR_MAX_IOVEC_SIZE



Mime
View raw message