}
-static apr_size_t h2_util_bl_print(char *buffer, apr_size_t bmax,
- const char *tag, const char *sep,
- h2_blist *bl)
-{
- apr_size_t off = 0;
- const char *sp = "";
- apr_bucket *b;
-
- if (bl) {
- memset(buffer, 0, bmax--);
- off += apr_snprintf(buffer+off, bmax-off, "%s(", tag);
- for (b = H2_BLIST_FIRST(bl);
- (bmax > off) && (b != H2_BLIST_SENTINEL(bl));
- b = APR_BUCKET_NEXT(b)) {
-
- off += h2_util_bucket_print(buffer+off, bmax-off, b, sp);
- sp = " ";
- }
- if (bmax > off) {
- off += apr_snprintf(buffer+off, bmax-off, ")%s", sep);
- }
- }
- else {
- off += apr_snprintf(buffer+off, bmax-off, "%s(null)%s", tag, sep);
- }
- return off;
-}
-
-
-
/*******************************************************************************
* bucket beam that can transport buckets across threads
******************************************************************************/
void h2_beam_log(h2_bucket_beam *beam, conn_rec *c, int level, const char *msg)
{
- if (0 && beam && APLOG_C_IS_LEVEL(c,level)) {
- char buffer[2048];
- apr_size_t blen = sizeof(buffer)/sizeof(buffer[0]) - 1;
- apr_size_t off = 0;
-
- buffer[0] = 0;
- off += apr_snprintf(buffer+off, blen-off, "cl=%d, ", beam->closed);
- off += h2_util_bl_print(buffer+off, blen-off, "to_send", ", ", &beam->send_list);
- if (blen > off) {
- off += h2_util_bb_print(buffer+off, blen-off, "recv_buffer", ", ", beam->recv_buffer);
- if (blen > off) {
- off += h2_util_bl_print(buffer+off, blen-off, "hold", ", ", &beam->hold_list);
- if (blen > off) {
- off += h2_util_bl_print(buffer+off, blen-off, "purge", "", &beam->purge_list);
- }
- }
- }
- buffer[blen-1] = 0;
- ap_log_cerror(APLOG_MARK, level, 0, c, "beam(%ld-%d,%s): %s %s",
- c->id, beam->id, beam->tag, msg, buffer);
+ if (beam && APLOG_C_IS_LEVEL(c,level)) {
+ ap_log_cerror(APLOG_MARK, level, 0, c,
+ "beam(%ld-%d,%s,closed=%d,aborted=%d,empty=%d,buf=%ld): %s",
+ c->id, beam->id, beam->tag, beam->closed, beam->aborted,
+ h2_beam_empty(beam), (long)h2_beam_get_buffered(beam),
+ msg);
}
}
conn_rec *slave = NULL;
int reuse_slave = 0;
- h2_beam_log(task->output.beam, m->c, APLOG_DEBUG,
- APLOGNO(03385) "h2_task_destroy");
-
slave = task->c;
reuse_slave = ((m->spare_slaves->nelts < m->spare_slaves->nalloc)
&& !task->rst_error);
if (slave) {
if (reuse_slave && slave->keepalive == AP_CONN_KEEPALIVE) {
+ h2_beam_log(task->output.beam, m->c, APLOG_DEBUG,
+ APLOGNO(03385) "h2_task_destroy, reuse slave");
h2_task_destroy(task);
APR_ARRAY_PUSH(m->spare_slaves, conn_rec*) = slave;
}
else {
+ h2_beam_log(task->output.beam, m->c, APLOG_TRACE1,
+ "h2_task_destroy, destroy slave");
slave->sbh = NULL;
h2_slave_destroy(slave);
}
ap_log_cerror(APLOG_MARK, APLOG_TRACE1, status, f->c,
"h2_slave_in(%s): get more data from mplx, block=%d, "
"readbytes=%ld", task->id, block, (long)readbytes);
-
- /* Override the block mode we get called with depending on the input's
- * setting. */
if (task->input.beam) {
status = h2_beam_receive(task->input.beam, task->input.bb, block,
H2MIN(readbytes, 32*1024));
}
}
- /* Inspect the buckets received, detect EOS and apply
- * chunked encoding if necessary */
+ /* Nothing there, no more data to get. Return APR_EAGAIN on
+ * speculative reads, this is ap_check_pipeline()'s trick to
+ * see if the connection needs closing. */
if (status == APR_EOF && APR_BRIGADE_EMPTY(task->input.bb)) {
- return APR_EOF;
+ return (mode == AP_MODE_SPECULATIVE)? APR_EAGAIN : APR_EOF;
}
h2_util_bb_log(f->c, task->stream_id, APLOG_TRACE2,