| 247 | } |
| 248 | |
| 249 | static apr_status_t pass_output(h2_c1_io *io, int flush) |
| 250 | { |
| 251 | conn_rec *c = io->session->c1; |
| 252 | apr_off_t bblen = 0; |
| 253 | apr_status_t rv; |
| 254 | |
| 255 | if (io->is_passing) { |
| 256 | /* recursive call, may be triggered by an H2EOS bucket |
| 257 | * being destroyed and triggering sending more data? */ |
| 258 | AP_DEBUG_ASSERT(0); |
| 259 | ap_log_cerror(APLOG_MARK, APLOG_ERR, 0, c, APLOGNO(10456) |
| 260 | "h2_c1_io(%ld): recursive call of h2_c1_io_pass. " |
| 261 | "Denied to prevent output corruption. This " |
| 262 | "points to a bug in the HTTP/2 implementation.", |
| 263 | c->id); |
| 264 | return APR_EGENERAL; |
| 265 | } |
| 266 | io->is_passing = 1; |
| 267 | |
| 268 | append_scratch(io); |
| 269 | if (flush) { |
| 270 | if (!APR_BUCKET_IS_FLUSH(APR_BRIGADE_LAST(io->output))) { |
| 271 | apr_bucket *b = apr_bucket_flush_create(c->bucket_alloc); |
| 272 | APR_BRIGADE_INSERT_TAIL(io->output, b); |
| 273 | } |
| 274 | } |
| 275 | if (APR_BRIGADE_EMPTY(io->output)) { |
| 276 | rv = APR_SUCCESS; |
| 277 | goto cleanup; |
| 278 | } |
| 279 | |
| 280 | io->unflushed = !APR_BUCKET_IS_FLUSH(APR_BRIGADE_LAST(io->output)); |
| 281 | apr_brigade_length(io->output, 0, &bblen); |
| 282 | C1_IO_BB_LOG(c, 0, APLOG_TRACE2, "out", io->output); |
| 283 | |
| 284 | rv = ap_pass_brigade(c->output_filters, io->output); |
| 285 | if (APR_SUCCESS != rv) goto cleanup; |
| 286 | io->bytes_written += (apr_size_t)bblen; |
| 287 | |
| 288 | if (io->write_size < WRITE_SIZE_MAX |
| 289 | && io->bytes_written >= io->warmup_size) { |
| 290 | /* connection is hot, use max size */ |
| 291 | io->write_size = WRITE_SIZE_MAX; |
| 292 | } |
| 293 | else if (io->cooldown_usecs > 0 |
| 294 | && io->write_size > WRITE_SIZE_INITIAL) { |
| 295 | apr_time_t now = apr_time_now(); |
| 296 | if ((now - io->last_write) >= io->cooldown_usecs) { |
| 297 | /* long time not written, reset write size */ |
| 298 | io->write_size = WRITE_SIZE_INITIAL; |
| 299 | io->bytes_written = 0; |
| 300 | } |
| 301 | else { |
| 302 | io->last_write = now; |
| 303 | } |
| 304 | } |
| 305 | |
| 306 | cleanup: |
no test coverage detected