Author: rhuijben
Date: Wed Nov 4 20:58:05 2015
New Revision: 1712648
URL: http://svn.apache.org/viewvc?rev=1712648&view=rev
Log:
Following up on r1712641, add some error checking and revert some accidentally
removed code that had multiple functions.
* buckets/mmap_buckets.c
(serf_mmap_read): Add error checking.
(serf_mmap_readline): Add error checking. Fix setting *len.
(serf_mmap_peek): Add error checking.
Modified:
serf/trunk/buckets/mmap_buckets.c
Modified: serf/trunk/buckets/mmap_buckets.c
URL:
http://svn.apache.org/viewvc/serf/trunk/buckets/mmap_buckets.c?rev=1712648&r1=1712647&r2=1712648&view=diff
==============================================================================
--- serf/trunk/buckets/mmap_buckets.c (original)
+++ serf/trunk/buckets/mmap_buckets.c Wed Nov 4 20:58:05 2015
@@ -54,6 +54,7 @@ static apr_status_t serf_mmap_read(serf_
const char **data, apr_size_t *len)
{
mmap_context_t *ctx = bucket->data;
+ apr_status_t status;
char *rd;
if (requested == SERF_READ_ALL_AVAIL || requested > ctx->remaining) {
@@ -64,7 +65,10 @@ static apr_status_t serf_mmap_read(serf_
}
/* ### Would it be faster to call this once and do the offset ourselves? */
- apr_mmap_offset(&rd, ctx->mmap, ctx->offset);
+ status = apr_mmap_offset(&rd, ctx->mmap, ctx->offset);
+ if (SERF_BUCKET_READ_ERROR(status))
+ return status;
+
*data = rd;
/* For the next read... */
@@ -82,13 +86,19 @@ static apr_status_t serf_mmap_readline(s
const char **data, apr_size_t *len)
{
mmap_context_t *ctx = bucket->data;
+ apr_status_t status;
char *end;
/* ### Would it be faster to call this once and do the offset ourselves? */
- apr_mmap_offset(&end, ctx->mmap, ctx->offset);
+ status = apr_mmap_offset(&end, ctx->mmap, ctx->offset);
+ if (SERF_BUCKET_READ_ERROR(status))
+ return status;
+
*data = end;
- serf_util_readline(&end, &ctx->remaining, acceptable, found);
+ *len = ctx->remaining;
+ serf_util_readline(&end, len, acceptable, found);
+ *len = end - *data;
ctx->offset += *len;
ctx->remaining -= *len;
@@ -104,10 +114,14 @@ static apr_status_t serf_mmap_peek(serf_
apr_size_t *len)
{
mmap_context_t *ctx = bucket->data;
+ apr_status_t status;
char *rd;
/* return whatever we have left */
- apr_mmap_offset(&rd, ctx->mmap, ctx->offset);
+ status = apr_mmap_offset(&rd, ctx->mmap, ctx->offset);
+ if (SERF_BUCKET_READ_ERROR(status))
+ return status;
+
*data = rd;
*len = ctx->remaining;