Author: rhuijben Date: Fri Nov 27 12:03:42 2015 New Revision: 1716857 URL: http://svn.apache.org/viewvc?rev=1716857&view=rev Log: Improve the handling of some early-eof scenarios in the split bucket.
* buckets/split_buckets.c (serf_split_read, serf_split_read_iovec): Handle EOF consistently. Either with an error in case of promissing more data earlier on, or by fixing this bucket and providing the right kind of EOF. Modified: serf/trunk/buckets/split_buckets.c Modified: serf/trunk/buckets/split_buckets.c URL: http://svn.apache.org/viewvc/serf/trunk/buckets/split_buckets.c?rev=1716857&r1=1716856&r2=1716857&view=diff ============================================================================== --- serf/trunk/buckets/split_buckets.c (original) +++ serf/trunk/buckets/split_buckets.c Fri Nov 27 12:03:42 2015 @@ -127,11 +127,18 @@ static apr_status_t serf_split_read(serf sctx->fixed_size = sctx->max_size = sctx->read_size; status = APR_EOF; } - else if (APR_STATUS_IS_EOF(status) - && (sctx->fixed_size && sctx->read_size != sctx->fixed_size)) { + else if (APR_STATUS_IS_EOF(status)) { + sctx->at_eof = true; - /* We promised more data via get_remaining() than we can deliver */ - status = SERF_ERROR_TRUNCATED_STREAM; + if (sctx->fixed_size && sctx->read_size != sctx->fixed_size) { + /* We promised more data via get_remaining() than we can + deliver. -> BAD get_remaining() */ + status = SERF_ERROR_TRUNCATED_STREAM; + } + else { + /* Ok, then this is our size */ + sctx->max_size = sctx->fixed_size = sctx->read_size; + } } } else @@ -197,6 +204,10 @@ static apr_status_t serf_split_read_iove deliver. -> BAD get_remaining() */ status = SERF_ERROR_TRUNCATED_STREAM; } + else { + /* Ok, then this is our size */ + sctx->max_size = sctx->fixed_size = sctx->read_size; + } } } else @@ -251,7 +262,7 @@ static apr_status_t serf_split_peek(serf sctx->cant_read = (*len > 0); } - else if (SERF_BUCKET_READ_ERROR(status)) + else sctx->cant_read = false; return status;