on_req_body_done, simplify by moving the ack before consume
@@ -374,7 +374,6 @@ static int write_body_chunk(void *priv, h2o_iovec_t body_chunk, int is_end, h2o_
static void on_req_body_done(h2o_socket_t *sock, const char *err)
{
struct st_h2o_http1client_private_t *client = sock->data;
- size_t to_ack = 0;
if (err) {
on_send_request(client->super.sock, err);
@@ -382,21 +381,17 @@ static void on_req_body_done(h2o_socket_t *sock, const char *err)
}
if (client->_body_buf_in_flight) {
- to_ack = client->_body_buf_in_flight->size;
+ client->_write_body_chunk_done(client->_write_body_chunk_done_ctx, client->_body_buf_in_flight->size,
+ client->_body_buf_is_done, 0);
h2o_buffer_consume(&client->_body_buf_in_flight, client->_body_buf_in_flight->size);
}
- if (client->_body_buf && client->_body_buf->size) {
+ if (client->_body_buf && client->_body_buf->size)
write_body_chunk(client->super.sock, h2o_iovec_init(NULL, 0), client->_body_buf_is_done, client->_write_body_chunk_done);
- } else {
- if (client->_body_buf_is_done)
+ else if (client->_body_buf_is_done)
on_send_request(client->super.sock, NULL);
}
- if (to_ack)
- client->_write_body_chunk_done(client->_write_body_chunk_done_ctx, to_ack, client->_body_buf_is_done, 0);
-}
-
static void swap_buffers(h2o_buffer_t **a, h2o_buffer_t **b)
{
h2o_buffer_t *swap;
