Skip to content

Commit 7f37ef3

Browse files
committed
minor fixes
1 parent 982f1ac commit 7f37ef3

2 files changed

Lines changed: 21 additions & 1 deletion

File tree

source/h1_connection.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1030,6 +1030,17 @@ static void s_on_channel_write_complete(
10301030
* to run again instead of calling the function directly.
10311031
* This way, if the message completes synchronously,
10321032
* we're not hogging the network by writing message after message in a tight loop */
1033+
1034+
/* If encoder is waiting for async body read, don't reschedule - the async callback will do it */
1035+
if (connection->thread_data.encoder.state == AWS_H1_ENCODER_STATE_ASYNC_WAITING) {
1036+
AWS_LOGF_TRACE(
1037+
AWS_LS_HTTP_CONNECTION,
1038+
"id=%p: Encoder waiting for async body, not rescheduling task.",
1039+
(void *)&connection->base);
1040+
connection->thread_data.is_outgoing_stream_task_active = false;
1041+
return;
1042+
}
1043+
10331044
aws_channel_schedule_task_now(channel, &connection->outgoing_stream_task);
10341045
}
10351046

@@ -1139,7 +1150,7 @@ static void s_write_outgoing_stream(struct aws_h1_connection *connection, bool f
11391150

11401151
goto error;
11411152
}
1142-
} else if(connection->thread_data.encoder.message->async_body) {
1153+
} else if(connection->thread_data.encoder.message && connection->thread_data.encoder.message->async_body) {
11431154
AWS_LOGF_TRACE(
11441155
AWS_LS_HTTP_CONNECTION,
11451156
"id=%p: Outgoing async stream task is either complete or waiting on future. Never reschedule task.",

source/h1_encoder.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ static int s_scan_outgoing_headers(
3333

3434
size_t total = 0;
3535
bool has_body_stream = aws_http_message_get_body_stream(message);
36+
if (!has_body_stream) {
37+
has_body_stream = aws_http_message_get_async_body_stream(message);
38+
}
3639
bool has_content_length_header = false;
3740
bool has_transfer_encoding_header = false;
3841

@@ -1087,6 +1090,12 @@ int aws_h1_encoder_process(struct aws_h1_encoder *encoder, struct aws_byte_buf *
10871090
enum aws_h1_encoder_state prev_state;
10881091
do {
10891092
prev_state = encoder->state;
1093+
1094+
/* Exit if waiting for async read - callback will resume encoding */
1095+
if (encoder->state == AWS_H1_ENCODER_STATE_ASYNC_WAITING) {
1096+
return AWS_OP_SUCCESS;
1097+
}
1098+
10901099
if (s_encoder_states[encoder->state].fn(encoder, out_buf)) {
10911100
return AWS_OP_ERR;
10921101
}

0 commit comments

Comments
 (0)