httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jerenkra...@apache.org
Subject svn commit: r595070 - /httpd/sandbox/amsterdam/d/modules/proxy/mod_serf.c
Date Wed, 14 Nov 2007 21:32:36 GMT
Author: jerenkrantz
Date: Wed Nov 14 13:32:35 2007
New Revision: 595070

URL: http://svn.apache.org/viewvc?rev=595070&view=rev
Log:
Amsterdam sandbox: Fix up ap_save_brigade semantics and correct read()
semantics per rpluem's comment.

Modified:
    httpd/sandbox/amsterdam/d/modules/proxy/mod_serf.c

Modified: httpd/sandbox/amsterdam/d/modules/proxy/mod_serf.c
URL: http://svn.apache.org/viewvc/httpd/sandbox/amsterdam/d/modules/proxy/mod_serf.c?rev=595070&r1=595069&r2=595070&view=diff
==============================================================================
--- httpd/sandbox/amsterdam/d/modules/proxy/mod_serf.c (original)
+++ httpd/sandbox/amsterdam/d/modules/proxy/mod_serf.c Wed Nov 14 13:32:35 2007
@@ -388,6 +388,7 @@
     serf_core_ctx_t *core_ctx;
     apr_bucket_brigade *bb;
     apr_bucket_brigade *tmp_bb;
+    apr_size_t last_read;
 } brigade_bucket_ctx_t;
 
 /* Forward-declare */
@@ -403,9 +404,10 @@
     ctx->allocator = core_ctx->serf_bkt_alloc;
     ctx->pool = serf_bucket_allocator_get_pool(ctx->allocator);
     ctx->core_ctx = core_ctx;
+    ctx->last_read = 0;
 
     /* Replace witha more optimized mechanism for converting */
-    ap_save_brigade(f, &ctx->bb, bb, f->c->pool);
+    ap_save_brigade(f, &ctx->bb, &bb, f->c->pool);
     ctx->tmp_bb = apr_brigade_create(f->c->pool, f->c->bucket_alloc);
 
     return serf_bucket_create(&serf_bucket_type_brigade, ctx->allocator, ctx);
@@ -417,20 +419,26 @@
 {
     brigade_bucket_ctx_t *ctx = bucket->data;
     apr_status_t status;
-    apr_bucket *b, *end, *f;
 
-    b = APR_BRIGADE_FIRST(ctx->bb);
-    status = apr_bucket_read(b, data, len, APR_BLOCK_READ);
+    if (ctx->last_read) {
+        apr_bucket *end, *f;
+        status = apr_brigade_partition(ctx->bb, ctx->last_read, &end);
+        f = APR_BRIGADE_FIRST(ctx->bb);
+        while (f != end && f != APR_BRIGADE_SENTINEL(ctx->bb)) {
+            apr_bucket_delete(f);
+            f = APR_BRIGADE_FIRST(ctx->bb);
+        }
+        ctx->last_read = 0;
+    }
+
+    status = apr_bucket_read(APR_BRIGADE_FIRST(ctx->bb), data, len,
+                             APR_BLOCK_READ);
 
     if (requested < *len) {
         *len = requested;
     }
-    status = apr_brigade_partition(ctx->bb, *len, &end);
-    f = APR_BRIGADE_FIRST(ctx->bb);
-    while (f != end && f != APR_BRIGADE_SENTINEL(ctx->bb)) {
-        apr_bucket_delete(f);
-        f = APR_BRIGADE_FIRST(ctx->bb);
-    }
+    ctx->last_read = *len;
+
     return status;
 }
 



Mime
View raw message