[core] connection_state_machine_h2() tweaks
@@ -1258,14 +1258,25 @@ connection_state_machine_h2 (request_st * const h2r, connection * const con)
connection_state_machine_loop(r, con);
- if (r->resp_header_len && !chunkqueue_is_empty(&r->write_queue)
+ #if 0
+ if (log_state_handling)
+ log_error(r->conf.errh, __FILE__, __LINE__,
+ "state at exit %d %d %s", con->fd, r->h2id,
+ connection_get_state(r->state));
+ #endif
+
+ if (r->state < CON_STATE_WRITE)
+ continue;
+ /* else CON_STATE_WRITE, CON_STATE_RESPONSE_END, CON_STATE_ERROR */
+ else if (r->state == CON_STATE_WRITE) {
+ if (__builtin_expect((!chunkqueue_is_empty(&r->write_queue)), 1)
&& max_bytes
&& (r->resp_body_finished
|| (r->conf.stream_response_body
& (FDEVENT_STREAM_RESPONSE
|FDEVENT_STREAM_RESPONSE_BUFMIN)))) {
-
- uint32_t dlen = max_bytes > 32768 ? 32768 : (uint32_t)max_bytes;
+ uint32_t dlen =
+ max_bytes > 32768 ? 32768 : (uint32_t)max_bytes;
dlen = h2_send_cqdata(r, con, &r->write_queue, dlen);
if (dlen) { /*(do not resched (spin) if swin empty window)*/
max_bytes -= (off_t)dlen;
@@ -1273,25 +1284,16 @@ connection_state_machine_h2 (request_st * const h2r, connection * const con)
resched |= 1;
}
}
+ if (!chunkqueue_is_empty(&r->write_queue)
+ || !r->resp_body_finished)
+ continue;
- {
- if (chunkqueue_is_empty(&r->write_queue)) {
- if (r->resp_body_finished && r->state == CON_STATE_WRITE) {
connection_set_state(r, CON_STATE_RESPONSE_END);
if (__builtin_expect( (r->conf.log_state_handling), 0))
connection_state_machine_loop(r, con);
}
- }
- }
-
- #if 0
- if (log_state_handling)
- log_error(r->conf.errh, __FILE__, __LINE__,
- "state at exit %d %d %s", con->fd, r->h2id,
- connection_get_state(r->state));
- #endif
- if (r->state==CON_STATE_RESPONSE_END || r->state==CON_STATE_ERROR) {
+ {/*(r->state==CON_STATE_RESPONSE_END || r->state==CON_STATE_ERROR)*/
/*(trigger reschedule of con if frames pending)*/
if (h2c->rused == sizeof(h2c->r)/sizeof(*h2c->r)
&& !chunkqueue_is_empty(con->read_queue))
