serf-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rhuij...@apache.org
Subject svn commit: r1711950 - in /serf/trunk: buckets/iovec_buckets.c test/test_buckets.c
Date Mon, 02 Nov 2015 12:49:52 GMT
Author: rhuijben
Date: Mon Nov  2 12:49:52 2015
New Revision: 1711950

URL: http://svn.apache.org/viewvc?rev=1711950&view=rev
Log:
Following up on r1711904, fix the bug that made me implement get_remaining
with the missed context problem.

* buckets/iovec_buckets.c
  (serf_iovec_peek): Properly return data when ctx->offset != 0.

* test/test_buckets.c
  (test_iovec_buckets): Add test for problem fixed in serf_iovec_peek.

Modified:
    serf/trunk/buckets/iovec_buckets.c
    serf/trunk/test/test_buckets.c

Modified: serf/trunk/buckets/iovec_buckets.c
URL: http://svn.apache.org/viewvc/serf/trunk/buckets/iovec_buckets.c?rev=1711950&r1=1711949&r2=1711950&view=diff
==============================================================================
--- serf/trunk/buckets/iovec_buckets.c (original)
+++ serf/trunk/buckets/iovec_buckets.c Mon Nov  2 12:49:52 2015
@@ -146,8 +146,8 @@ static apr_status_t serf_iovec_peek(serf
 
     /* Return the first unread buffer, don't bother combining all
        remaining data. */
-    *data = ctx->vecs[ctx->current_vec].iov_base;
-    *len = ctx->vecs[ctx->current_vec].iov_len;
+    *data = (const char *)ctx->vecs[ctx->current_vec].iov_base + ctx->offset;
+    *len = ctx->vecs[ctx->current_vec].iov_len - ctx->offset;
 
     if (ctx->current_vec + 1 == ctx->vecs_len)
         return APR_EOF;

Modified: serf/trunk/test/test_buckets.c
URL: http://svn.apache.org/viewvc/serf/trunk/test/test_buckets.c?rev=1711950&r1=1711949&r2=1711950&view=diff
==============================================================================
--- serf/trunk/test/test_buckets.c (original)
+++ serf/trunk/test/test_buckets.c Mon Nov  2 12:49:52 2015
@@ -478,6 +478,10 @@ static void test_iovec_buckets(CuTest *t
     CuAssert(tc, tgt_vecs[0].iov_base,
              strncmp("lin", tgt_vecs[0].iov_base, tgt_vecs[0].iov_len) == 0);
 
+    status = serf_bucket_peek(iobkt, &data, &len);
+    CuAssertTrue(tc, (status == APR_SUCCESS) || APR_STATUS_IS_EOF(status));
+    CuAssertIntEquals(tc, 0, memcmp(data, "e1" CRLF "line2", len));
+
     /* Check serf_bucket_get_remaining() result. */
     CuAssertIntEquals(tc, 9, (int)serf_bucket_get_remaining(iobkt));
 



Mime
View raw message