serf-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rhuij...@apache.org
Subject svn commit: r1708112 - in /serf/trunk: ./ buckets/ test/
Date Mon, 12 Oct 2015 13:27:22 GMT
Author: rhuijben
Date: Mon Oct 12 13:27:21 2015
New Revision: 1708112

URL: http://svn.apache.org/viewvc?rev=1708112&view=rev
Log:
Merge the get-remaining branch back to trunk to add a few more testcases
on v2 buckets.

Modified:
    serf/trunk/   (props changed)
    serf/trunk/buckets/aggregate_buckets.c
    serf/trunk/buckets/barrier_buckets.c
    serf/trunk/buckets/buckets.c
    serf/trunk/buckets/chunk_buckets.c
    serf/trunk/buckets/copy_buckets.c
    serf/trunk/buckets/dechunk_buckets.c
    serf/trunk/buckets/deflate_buckets.c
    serf/trunk/buckets/file_buckets.c
    serf/trunk/buckets/limit_buckets.c
    serf/trunk/buckets/log_wrapper_buckets.c
    serf/trunk/buckets/mmap_buckets.c
    serf/trunk/buckets/request_buckets.c
    serf/trunk/buckets/response_body_buckets.c
    serf/trunk/buckets/response_buckets.c
    serf/trunk/buckets/simple_buckets.c
    serf/trunk/buckets/socket_buckets.c
    serf/trunk/buckets/ssl_buckets.c
    serf/trunk/serf.h
    serf/trunk/serf_bucket_util.h
    serf/trunk/test/mock_sock_buckets.c
    serf/trunk/test/test_buckets.c

Propchange: serf/trunk/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon Oct 12 13:27:21 2015
@@ -1,4 +1,5 @@
 /serf/branches/copy-bucket:1699343-1699443
 /serf/branches/fix-authn-errors:1699959-1700007
+/serf/branches/get-remaining:1701859-1708111
 /serf/branches/multiple_ssl_impls:1699382
 /serf/branches/windows-sspi:1698866-1698877

Modified: serf/trunk/buckets/aggregate_buckets.c
URL: http://svn.apache.org/viewvc/serf/trunk/buckets/aggregate_buckets.c?rev=1708112&r1=1708111&r2=1708112&view=diff
==============================================================================
--- serf/trunk/buckets/aggregate_buckets.c (original)
+++ serf/trunk/buckets/aggregate_buckets.c Mon Oct 12 13:27:21 2015
@@ -492,6 +492,29 @@ static serf_bucket_t * serf_aggregate_re
     return serf_bucket_read_bucket(ctx->list->bucket, type);
 }
 
+static apr_uint64_t serf_aggregate_get_remaining(serf_bucket_t *bucket)
+{
+    aggregate_context_t *ctx = bucket->data;
+    apr_uint64_t remaining = 0;
+    bucket_list_t *cur;
+
+    if (ctx->hold_open) {
+        return SERF_LENGTH_UNKNOWN;
+    }
+
+    for(cur = ctx->list; cur != NULL; cur = cur->next) {
+        apr_uint64_t bucket_remaining = serf_bucket_get_remaining(cur->bucket);
+
+        if (bucket_remaining == SERF_LENGTH_UNKNOWN) {
+            return SERF_LENGTH_UNKNOWN;
+        }
+
+        remaining += bucket_remaining;
+    }
+
+    return remaining;
+}
+
 static apr_status_t serf_aggregate_set_config(serf_bucket_t *bucket,
                                               serf_config_t *config)
 {
@@ -524,5 +547,6 @@ const serf_bucket_type_t serf_bucket_typ
     serf_aggregate_peek,
     serf_aggregate_destroy_and_data,
     serf_aggregate_read_bucket,
+    serf_aggregate_get_remaining,
     serf_aggregate_set_config,
 };

Modified: serf/trunk/buckets/barrier_buckets.c
URL: http://svn.apache.org/viewvc/serf/trunk/buckets/barrier_buckets.c?rev=1708112&r1=1708111&r2=1708112&view=diff
==============================================================================
--- serf/trunk/buckets/barrier_buckets.c (original)
+++ serf/trunk/buckets/barrier_buckets.c Mon Oct 12 13:27:21 2015
@@ -79,6 +79,13 @@ static void serf_barrier_destroy(serf_bu
     serf_default_destroy(bucket);
 }
 
+static apr_uint64_t serf_barrier_get_remaining(serf_bucket_t *bucket)
+{
+    serf_bucket_t *stream = bucket->data;
+
+    return serf_bucket_get_remaining(stream);
+}
+
 static apr_status_t serf_barrier_set_config(serf_bucket_t *bucket,
                                             serf_config_t *config)
 {
@@ -99,5 +106,6 @@ const serf_bucket_type_t serf_bucket_typ
     serf_barrier_peek,
     serf_barrier_destroy,
     serf_default_read_bucket,
+    serf_barrier_get_remaining,
     serf_barrier_set_config,
 };

Modified: serf/trunk/buckets/buckets.c
URL: http://svn.apache.org/viewvc/serf/trunk/buckets/buckets.c?rev=1708112&r1=1708111&r2=1708112&view=diff
==============================================================================
--- serf/trunk/buckets/buckets.c (original)
+++ serf/trunk/buckets/buckets.c Mon Oct 12 13:27:21 2015
@@ -129,6 +129,10 @@ void serf_default_destroy_and_data(serf_
     serf_default_destroy(bucket);
 }
 
+apr_uint64_t *serf_default_get_remaining(serf_bucket_t *bucket)
+{
+    return SERF_LENGTH_UNKNOWN;
+}
 
 serf_bucket_t * serf_buckets_are_v2(serf_bucket_t *bucket,
                                     const serf_bucket_type_t *type)

Modified: serf/trunk/buckets/chunk_buckets.c
URL: http://svn.apache.org/viewvc/serf/trunk/buckets/chunk_buckets.c?rev=1708112&r1=1708111&r2=1708112&view=diff
==============================================================================
--- serf/trunk/buckets/chunk_buckets.c (original)
+++ serf/trunk/buckets/chunk_buckets.c Mon Oct 12 13:27:21 2015
@@ -255,5 +255,6 @@ const serf_bucket_type_t serf_bucket_typ
     serf_chunk_peek,
     serf_chunk_destroy,
     serf_default_read_bucket,
+    serf_default_get_remaining,
     serf_chunk_set_config,
 };

Modified: serf/trunk/buckets/copy_buckets.c
URL: http://svn.apache.org/viewvc/serf/trunk/buckets/copy_buckets.c?rev=1708112&r1=1708111&r2=1708112&view=diff
==============================================================================
--- serf/trunk/buckets/copy_buckets.c (original)
+++ serf/trunk/buckets/copy_buckets.c Mon Oct 12 13:27:21 2015
@@ -198,5 +198,6 @@ const serf_bucket_type_t serf_bucket_typ
     serf_copy_peek,
     serf_copy_destroy,
     serf_copy_read_bucket,
+    serf_default_get_remaining,
     serf_copy_set_config,
 };

Modified: serf/trunk/buckets/dechunk_buckets.c
URL: http://svn.apache.org/viewvc/serf/trunk/buckets/dechunk_buckets.c?rev=1708112&r1=1708111&r2=1708112&view=diff
==============================================================================
--- serf/trunk/buckets/dechunk_buckets.c (original)
+++ serf/trunk/buckets/dechunk_buckets.c Mon Oct 12 13:27:21 2015
@@ -205,12 +205,13 @@ static apr_status_t serf_dechunk_set_con
 const serf_bucket_type_t serf_bucket_type_dechunk = {
     "DECHUNK",
     serf_dechunk_read,
-    serf_dechunk_readline,
+    serf_dechunk_readline /* ### TODO */,
     serf_default_read_iovec,
     serf_default_read_for_sendfile,
     serf_buckets_are_v2,
-    serf_dechunk_peek,
+    serf_dechunk_peek /* ### TODO */,
     serf_dechunk_destroy_and_data,
     serf_default_read_bucket,
+    serf_default_get_remaining,
     serf_dechunk_set_config,
 };

Modified: serf/trunk/buckets/deflate_buckets.c
URL: http://svn.apache.org/viewvc/serf/trunk/buckets/deflate_buckets.c?rev=1708112&r1=1708111&r2=1708112&view=diff
==============================================================================
--- serf/trunk/buckets/deflate_buckets.c (original)
+++ serf/trunk/buckets/deflate_buckets.c Mon Oct 12 13:27:21 2015
@@ -451,12 +451,13 @@ static apr_status_t serf_deflate_set_con
 const serf_bucket_type_t serf_bucket_type_deflate = {
     "DEFLATE",
     serf_deflate_read,
-    serf_deflate_readline,
+    serf_deflate_readline /* ### TODO */,
     serf_default_read_iovec,
     serf_default_read_for_sendfile,
     serf_buckets_are_v2,
-    serf_deflate_peek,
+    serf_deflate_peek /* ### TODO */,
     serf_deflate_destroy_and_data,
     serf_default_read_bucket,
+    serf_default_get_remaining,
     serf_deflate_set_config,
 };

Modified: serf/trunk/buckets/file_buckets.c
URL: http://svn.apache.org/viewvc/serf/trunk/buckets/file_buckets.c?rev=1708112&r1=1708111&r2=1708112&view=diff
==============================================================================
--- serf/trunk/buckets/file_buckets.c (original)
+++ serf/trunk/buckets/file_buckets.c Mon Oct 12 13:27:21 2015
@@ -27,6 +27,7 @@ typedef struct file_context_t {
     apr_file_t *file;
 
     serf_databuf_t databuf;
+    apr_uint64_t remaining;
 } file_context_t;
 
 
@@ -45,11 +46,11 @@ serf_bucket_t *serf_bucket_file_create(
 {
     apr_status_t status;
     file_context_t *ctx;
-#if APR_HAS_MMAP
     apr_finfo_t finfo;
 
     status = apr_file_info_get(&finfo, APR_FINFO_SIZE, file);
 
+#if APR_HAS_MMAP
     /* See if we'd be better off mmap'ing this file instead.
      *
      * Note that there is a failure case here that we purposely fall through:
@@ -77,6 +78,13 @@ serf_bucket_t *serf_bucket_file_create(
     ctx->databuf.read = file_reader;
     ctx->databuf.read_baton = ctx;
 
+    if (status == APR_SUCCESS) {
+        ctx->remaining = finfo.size;
+    }
+    else {
+        ctx->remaining = SERF_LENGTH_UNKNOWN;
+    }
+
     return serf_bucket_create(&serf_bucket_type_file, allocator, ctx);
 }
 
@@ -85,8 +93,21 @@ static apr_status_t serf_file_read(serf_
                                    const char **data, apr_size_t *len)
 {
     file_context_t *ctx = bucket->data;
+    apr_status_t status;
+
+    status = serf_databuf_read(&ctx->databuf, requested, data, len);
+
+    if (SERF_BUCKET_READ_ERROR(status))
+    {
+        return status;
+    }
+
+    /* Update remaining length if known. */
+    if (ctx->remaining != SERF_LENGTH_UNKNOWN) {
+        ctx->remaining -= *len;
+    }
 
-    return serf_databuf_read(&ctx->databuf, requested, data, len);
+    return status;
 }
 
 static apr_status_t serf_file_readline(serf_bucket_t *bucket,
@@ -94,8 +115,22 @@ static apr_status_t serf_file_readline(s
                                        const char **data, apr_size_t *len)
 {
     file_context_t *ctx = bucket->data;
+    apr_status_t status;
+
+    status = serf_databuf_readline(&ctx->databuf, acceptable, found, data, len);
+
+    if (SERF_BUCKET_READ_ERROR(status))
+    {
+        return status;
+    }
+
+    /* Update remaining length if known. */
+    if (ctx->remaining != SERF_LENGTH_UNKNOWN) {
+        ctx->remaining -= *len;
+    }
+
+    return status;
 
-    return serf_databuf_readline(&ctx->databuf, acceptable, found, data, len);
 }
 
 static apr_status_t serf_file_peek(serf_bucket_t *bucket,
@@ -107,6 +142,12 @@ static apr_status_t serf_file_peek(serf_
     return serf_databuf_peek(&ctx->databuf, data, len);
 }
 
+static apr_uint64_t serf_file_get_remaining(serf_bucket_t *bucket)
+{
+    file_context_t *ctx = bucket->data;
+    return ctx->remaining;
+}
+
 const serf_bucket_type_t serf_bucket_type_file = {
     "FILE",
     serf_file_read,
@@ -117,5 +158,6 @@ const serf_bucket_type_t serf_bucket_typ
     serf_file_peek,
     serf_default_destroy_and_data,
     serf_default_read_bucket,
+    serf_file_get_remaining,
     serf_default_ignore_config,
 };

Modified: serf/trunk/buckets/limit_buckets.c
URL: http://svn.apache.org/viewvc/serf/trunk/buckets/limit_buckets.c?rev=1708112&r1=1708111&r2=1708112&view=diff
==============================================================================
--- serf/trunk/buckets/limit_buckets.c (original)
+++ serf/trunk/buckets/limit_buckets.c Mon Oct 12 13:27:21 2015
@@ -121,6 +121,13 @@ static void serf_limit_destroy(serf_buck
     serf_default_destroy_and_data(bucket);
 }
 
+static apr_uint64_t serf_limit_get_remaining(serf_bucket_t *bucket)
+{
+    limit_context_t *ctx = bucket->data;
+
+    return ctx->remaining;
+}
+
 static apr_status_t serf_limit_set_config(serf_bucket_t *bucket,
                                           serf_config_t *config)
 {
@@ -141,5 +148,6 @@ const serf_bucket_type_t serf_bucket_typ
     serf_limit_peek,
     serf_limit_destroy,
     serf_default_read_bucket,
+    serf_limit_get_remaining,
     serf_limit_set_config,
 };

Modified: serf/trunk/buckets/log_wrapper_buckets.c
URL: http://svn.apache.org/viewvc/serf/trunk/buckets/log_wrapper_buckets.c?rev=1708112&r1=1708111&r2=1708112&view=diff
==============================================================================
--- serf/trunk/buckets/log_wrapper_buckets.c (original)
+++ serf/trunk/buckets/log_wrapper_buckets.c Mon Oct 12 13:27:21 2015
@@ -161,6 +161,7 @@ serf_bucket_t *serf__bucket_log_wrapper_
     bkt_type->read_for_sendfile = wrapped->type->read_for_sendfile;
     if (wrapped->type->read_bucket == serf_buckets_are_v2) {
         bkt_type->read_bucket_v2 = wrapped->type->read_bucket_v2;
+        bkt_type->get_remaining = wrapped->type->get_remaining;
     }
 
     /* Wrap these functions */

Modified: serf/trunk/buckets/mmap_buckets.c
URL: http://svn.apache.org/viewvc/serf/trunk/buckets/mmap_buckets.c?rev=1708112&r1=1708111&r2=1708112&view=diff
==============================================================================
--- serf/trunk/buckets/mmap_buckets.c (original)
+++ serf/trunk/buckets/mmap_buckets.c Mon Oct 12 13:27:21 2015
@@ -118,6 +118,12 @@ static apr_status_t serf_mmap_peek(serf_
     return APR_EOF;
 }
 
+static apr_uint64_t serf_mmap_get_remaining(serf_bucket_t *bucket)
+{
+    mmap_context_t *ctx = bucket->data;
+    return ctx->remaining;
+}
+
 const serf_bucket_type_t serf_bucket_type_mmap = {
     "MMAP",
     serf_mmap_read,
@@ -128,6 +134,7 @@ const serf_bucket_type_t serf_bucket_typ
     serf_mmap_peek,
     serf_default_destroy_and_data,
     serf_default_read_bucket,
+    serf_mmap_get_remaining,
     serf_default_ignore_config,
 };
 
@@ -144,6 +151,7 @@ const serf_bucket_type_t serf_bucket_typ
     NULL,
     NULL,
     NULL,
+    NULL,
     NULL,
     NULL,
     NULL,

Modified: serf/trunk/buckets/request_buckets.c
URL: http://svn.apache.org/viewvc/serf/trunk/buckets/request_buckets.c?rev=1708112&r1=1708111&r2=1708112&view=diff
==============================================================================
--- serf/trunk/buckets/request_buckets.c (original)
+++ serf/trunk/buckets/request_buckets.c Mon Oct 12 13:27:21 2015
@@ -245,6 +245,7 @@ const serf_bucket_type_t serf_bucket_typ
     serf_request_peek,
     serf_request_destroy,
     serf_default_read_bucket,
+    serf_default_get_remaining,
     serf_request_set_config,
 };
 

Modified: serf/trunk/buckets/response_body_buckets.c
URL: http://svn.apache.org/viewvc/serf/trunk/buckets/response_body_buckets.c?rev=1708112&r1=1708111&r2=1708112&view=diff
==============================================================================
--- serf/trunk/buckets/response_body_buckets.c (original)
+++ serf/trunk/buckets/response_body_buckets.c Mon Oct 12 13:27:21 2015
@@ -149,5 +149,6 @@ const serf_bucket_type_t serf_bucket_typ
     serf_response_body_peek,
     serf_response_body_destroy,
     serf_default_read_bucket,
+    serf_default_get_remaining,
     serf_response_body_set_config,
 };

Modified: serf/trunk/buckets/response_buckets.c
URL: http://svn.apache.org/viewvc/serf/trunk/buckets/response_buckets.c?rev=1708112&r1=1708111&r2=1708112&view=diff
==============================================================================
--- serf/trunk/buckets/response_buckets.c (original)
+++ serf/trunk/buckets/response_buckets.c Mon Oct 12 13:27:21 2015
@@ -542,8 +542,9 @@ const serf_bucket_type_t serf_bucket_typ
     serf_default_read_iovec,
     serf_default_read_for_sendfile,
     serf_buckets_are_v2,
-    serf_response_peek,
+    serf_response_peek /* ### TODO */,
     serf_response_destroy_and_data,
     serf_default_read_bucket,
+    serf_default_get_remaining,
     serf_response_set_config,
 };

Modified: serf/trunk/buckets/simple_buckets.c
URL: http://svn.apache.org/viewvc/serf/trunk/buckets/simple_buckets.c?rev=1708112&r1=1708111&r2=1708112&view=diff
==============================================================================
--- serf/trunk/buckets/simple_buckets.c (original)
+++ serf/trunk/buckets/simple_buckets.c Mon Oct 12 13:27:21 2015
@@ -153,6 +153,12 @@ static void serf_simple_destroy(serf_buc
     serf_default_destroy_and_data(bucket);
 }
 
+static apr_uint64_t serf_simple_get_remaining(serf_bucket_t *bucket)
+{
+    simple_context_t *ctx = bucket->data;
+    return ctx->remaining;
+}
+
 const serf_bucket_type_t serf_bucket_type_simple = {
     "SIMPLE",
     serf_simple_read,
@@ -163,5 +169,6 @@ const serf_bucket_type_t serf_bucket_typ
     serf_simple_peek,
     serf_simple_destroy,
     serf_default_read_bucket,
+    serf_simple_get_remaining,
     serf_default_ignore_config,
 };

Modified: serf/trunk/buckets/socket_buckets.c
URL: http://svn.apache.org/viewvc/serf/trunk/buckets/socket_buckets.c?rev=1708112&r1=1708111&r2=1708112&view=diff
==============================================================================
--- serf/trunk/buckets/socket_buckets.c (original)
+++ serf/trunk/buckets/socket_buckets.c Mon Oct 12 13:27:21 2015
@@ -119,5 +119,6 @@ const serf_bucket_type_t serf_bucket_typ
     serf_socket_peek,
     serf_default_destroy_and_data,
     serf_default_read_bucket,
+    serf_default_get_remaining,
     serf_default_ignore_config,
 };

Modified: serf/trunk/buckets/ssl_buckets.c
URL: http://svn.apache.org/viewvc/serf/trunk/buckets/ssl_buckets.c?rev=1708112&r1=1708111&r2=1708112&view=diff
==============================================================================
--- serf/trunk/buckets/ssl_buckets.c (original)
+++ serf/trunk/buckets/ssl_buckets.c Mon Oct 12 13:27:21 2015
@@ -2161,6 +2161,7 @@ const serf_bucket_type_t serf_bucket_typ
     serf_ssl_peek,
     serf_ssl_encrypt_destroy_and_data,
     serf_default_read_bucket,
+    serf_default_get_remaining,
     serf_ssl_set_config,
 };
 
@@ -2174,5 +2175,6 @@ const serf_bucket_type_t serf_bucket_typ
     serf_ssl_peek,
     serf_ssl_decrypt_destroy_and_data,
     serf_default_read_bucket,
+    serf_default_get_remaining,
     serf_ssl_set_config,
 };

Modified: serf/trunk/serf.h
URL: http://svn.apache.org/viewvc/serf/trunk/serf.h?rev=1708112&r1=1708111&r2=1708112&view=diff
==============================================================================
--- serf/trunk/serf.h (original)
+++ serf/trunk/serf.h Mon Oct 12 13:27:21 2015
@@ -779,6 +779,11 @@ serf_bucket_t *serf_request_bucket_reque
  */
 #define SERF_NEWLINE_CRLF_SPLIT 0x0010
 
+/** Used to indicate that length of remaining data in bucket is unknown. See 
+ * serf_bucket_type_t->get_remaining().
+ */
+#define SERF_LENGTH_UNKNOWN ((apr_uint64_t) -1)
+
 struct serf_bucket_type_t {
 
     /** name of this bucket type */
@@ -923,6 +928,13 @@ struct serf_bucket_type_t {
     serf_bucket_t * (*read_bucket_v2)(serf_bucket_t *bucket,
                                       const serf_bucket_type_t *type);
 
+    /* Returns length of remaining data to be read in @a bucket. Returns
+     * SERF_LENGTH_UNKNOWN if length is unknown.
+     *
+     * @since New in 1.4.
+     */
+    apr_uint64_t (*get_remaining)(serf_bucket_t *bucket);
+
     /* Provides a reference to a config object containing all configuration
      * values relevant for this bucket.
      *
@@ -981,6 +993,10 @@ serf_bucket_t * serf_buckets_are_v2(serf
 #define serf_bucket_read_bucket(b,t) ((b)->type->read_bucket(b,t))
 #define serf_bucket_peek(b,d,l) ((b)->type->peek(b,d,l))
 #define serf_bucket_destroy(b) ((b)->type->destroy(b))
+#define serf_bucket_get_remaining(b) \
+            ((b)->type->read_bucket == serf_buckets_are_v2 ? \
+             (b)->type->get_remaining(b) : \
+             SERF_LENGTH_UNKNOWN)
 #define serf_bucket_set_config(b,c) \
             ((b)->type->read_bucket == serf_buckets_are_v2 ? \
             (b)->type->set_config(b,c) : \

Modified: serf/trunk/serf_bucket_util.h
URL: http://svn.apache.org/viewvc/serf/trunk/serf_bucket_util.h?rev=1708112&r1=1708111&r2=1708112&view=diff
==============================================================================
--- serf/trunk/serf_bucket_util.h (original)
+++ serf/trunk/serf_bucket_util.h Mon Oct 12 13:27:21 2015
@@ -103,6 +103,14 @@ void serf_default_destroy_and_data(
     serf_bucket_t *bucket);
 
 /**
+ * Default implementation of the @see get_remaining functionality.
+ *
+ * This function will just return SERF_LENGTH_UNKNOWN.
+ */
+apr_uint64_t *serf_default_get_remaining(
+    serf_bucket_t *bucket);
+
+/**
  * Default implementation of the @see set_config functionality.
  *
  * This function will not do anything, it should be used in buckets

Modified: serf/trunk/test/mock_sock_buckets.c
URL: http://svn.apache.org/viewvc/serf/trunk/test/mock_sock_buckets.c?rev=1708112&r1=1708111&r2=1708112&view=diff
==============================================================================
--- serf/trunk/test/mock_sock_buckets.c (original)
+++ serf/trunk/test/mock_sock_buckets.c Mon Oct 12 13:27:21 2015
@@ -95,5 +95,6 @@ const serf_bucket_type_t serf_bucket_typ
     serf_mock_sock_peek,
     serf_default_destroy_and_data,
     serf_default_read_bucket,
+    serf_default_get_remaining,
     serf_mock_sock_set_config,
 };

Modified: serf/trunk/test/test_buckets.c
URL: http://svn.apache.org/viewvc/serf/trunk/test/test_buckets.c?rev=1708112&r1=1708111&r2=1708112&view=diff
==============================================================================
--- serf/trunk/test/test_buckets.c (original)
+++ serf/trunk/test/test_buckets.c Mon Oct 12 13:27:21 2015
@@ -606,6 +606,12 @@ static void test_aggregate_buckets(CuTes
     bkt = SERF_BUCKET_SIMPLE_STRING(BODY, alloc);
     serf_bucket_aggregate_append(aggbkt, bkt);
 
+    /* If you see result -1 in the next line, this is most likely caused by
+       not properly detecting v2 buckets via the magic function pointer.
+       Most likely you are seeing a linkage problem which causes seeing
+       different pointers for serf_buckets_are_v2() */
+    CuAssertIntEquals(tc, 62, (int)serf_bucket_get_remaining(aggbkt));
+
     status = serf_bucket_read_iovec(aggbkt, 0, 32,
                                     tgt_vecs, &vecs_used);
     CuAssertIntEquals(tc, APR_SUCCESS, status);
@@ -635,6 +641,8 @@ static void test_aggregate_buckets(CuTes
     bkt = SERF_BUCKET_SIMPLE_STRING_LEN(BODY+15, strlen(BODY)-15, alloc);
     serf_bucket_aggregate_append(aggbkt, bkt);
 
+    CuAssertTrue(tc, serf_bucket_get_remaining(aggbkt) == 62);
+
     read_and_check_bucket(tc, aggbkt, BODY);
 
     /* Test 5: multiple child buckets prepended. */
@@ -645,6 +653,8 @@ static void test_aggregate_buckets(CuTes
     bkt = SERF_BUCKET_SIMPLE_STRING_LEN(BODY, 15, alloc);
     serf_bucket_aggregate_prepend(aggbkt, bkt);
 
+    CuAssertTrue(tc, serf_bucket_get_remaining(aggbkt) == 62);
+
     read_and_check_bucket(tc, aggbkt, BODY);
 
     /* Test 6: ensure peek doesn't return APR_EAGAIN, or APR_EOF incorrectly. */



Mime
View raw message