apr_status_t h2_beam_receive(h2_bucket_beam *beam,
apr_bucket_brigade *bb,
apr_read_type_e block,
- apr_off_t readbytes)
+ apr_off_t readbytes,
+ int *pclosed)
{
h2_beam_lock bl;
apr_bucket *bsender, *brecv, *ng;
apr_status_t status = APR_SUCCESS;
apr_off_t remain;
int transferred_buckets = 0;
-
+
/* Called from the receiver thread to take buckets from the beam */
if (enter_yellow(beam, &bl) == APR_SUCCESS) {
if (readbytes <= 0) {
}
goto transfer;
}
-leave:
+leave:
+ if (pclosed) *pclosed = beam->closed? 1 : 0;
leave_yellow(beam, &bl);
}
return status;
* if no data is available.
*
* Call from the receiver side only.
+ * @param pclosed on return != 0 iff the beam has been closed by the sender. It
+ * may still hold untransfered data. Maybe NULL if the caller is
+ * not interested in this.
*/
apr_status_t h2_beam_receive(h2_bucket_beam *beam,
apr_bucket_brigade *green_buckets,
apr_read_type_e block,
- apr_off_t readbytes);
+ apr_off_t readbytes,
+ int *pclosed);
/**
* Determine if beam is empty.
apr_status_t status = APR_SUCCESS;
apr_off_t requested, missing, max_chunk = H2_DATA_CHUNK_SIZE;
conn_rec *c;
- int complete;
+ int complete, was_closed = 0;
ap_assert(stream);
if (stream->output) {
H2_STREAM_OUT_LOG(APLOG_TRACE2, stream, "pre");
- rv = h2_beam_receive(stream->output, stream->out_buffer,
- APR_NONBLOCK_READ, stream->max_mem - *plen);
+ h2_beam_log(stream->output, c, APLOG_TRACE2, "pre read output");
+ rv = h2_beam_receive(stream->output, stream->out_buffer,
+ APR_NONBLOCK_READ, stream->max_mem - *plen, &was_closed);
H2_STREAM_OUT_LOG(APLOG_TRACE2, stream, "post");
+ h2_beam_log(stream->output, c, APLOG_TRACE2, "post read output");
}
if (rv == APR_SUCCESS) {
(long)*plen, *peos);
}
else {
- status = (stream->output && h2_beam_is_closed(stream->output))? APR_EOF : APR_EAGAIN;
+ status = was_closed? APR_EOF : APR_EAGAIN;
ap_log_cerror(APLOG_MARK, APLOG_TRACE1, 0, c,
H2_STRM_MSG(stream, "prepare, no data"));
}