diff --git a/include/aws/http/private/h1_connection.h b/include/aws/http/private/h1_connection.h index 2739f6ef4..e303eeb8d 100644 --- a/include/aws/http/private/h1_connection.h +++ b/include/aws/http/private/h1_connection.h @@ -7,6 +7,85 @@ */ #include +#include +#include + +struct aws_h1_connection { + struct aws_http_connection base; + + size_t initial_window_size; + + /* Single task used repeatedly for sending data from streams. */ + struct aws_channel_task outgoing_stream_task; + + /* Single task used for issuing window updates from off-thread */ + struct aws_channel_task window_update_task; + + /* Only the event-loop thread may touch this data */ + struct { + /* List of streams being worked on. */ + struct aws_linked_list stream_list; + + /* Points to the stream whose data is currently being sent. + * This stream is ALWAYS in the `stream_list`. + * HTTP pipelining is supported, so once the stream is completely written + * we'll start working on the next stream in the list */ + struct aws_h1_stream *outgoing_stream; + + /* Points to the stream being decoded. + * This stream is ALWAYS in the `stream_list`. */ + struct aws_h1_stream *incoming_stream; + struct aws_h1_decoder *incoming_stream_decoder; + + /* Used to encode requests and responses */ + struct aws_h1_encoder encoder; + + /* Amount to let read-window shrink after a channel message has been processed. */ + size_t incoming_message_window_shrink_size; + + /* Messages received after the connection has switched protocols. + * These are passed downstream to the next handler. */ + struct aws_linked_list midchannel_read_messages; + + /* True when read and/or writing has stopped, whether due to errors or normal channel shutdown. */ + bool is_reading_stopped; + bool is_writing_stopped; + + /* If true, the connection has upgraded to another protocol. + * It will pass data to adjacent channel handlers without altering it. + * The connection can no longer service request/response streams. */ + bool has_switched_protocols; + + /* Server-only. Request-handler streams can only be created while this is true. */ + bool can_create_request_handler_stream; + + struct aws_crt_statistics_http1_channel stats; + + uint64_t outgoing_stream_timestamp_ns; + uint64_t incoming_stream_timestamp_ns; + + } thread_data; + + /* Any thread may touch this data, but the lock must be held */ + struct { + struct aws_mutex lock; + + /* New client streams that have not been moved to `stream_list` yet. + * This list is not used on servers. */ + struct aws_linked_list new_client_stream_list; + + bool is_outgoing_stream_task_active; + + /* For checking status from outside the event-loop thread. */ + bool is_open; + + /* If non-zero, then window_update_task is scheduled */ + size_t window_update_size; + + /* If non-zero, reason to immediately reject new streams. (ex: closing) */ + int new_stream_error_code; + } synced_data; +}; AWS_EXTERN_C_BEGIN @@ -24,4 +103,9 @@ struct aws_http_connection *aws_http_connection_new_http1_1_client( AWS_EXTERN_C_END +/* DO NOT export functions below. They're used by other .c files in this library */ + +void aws_h1_connection_lock_synced_data(struct aws_h1_connection *connection); +void aws_h1_connection_unlock_synced_data(struct aws_h1_connection *connection); + #endif /* AWS_HTTP_H1_CONNECTION_H */ diff --git a/source/h1_connection.c b/source/h1_connection.c index 843cc886e..ff1f837de 100644 --- a/source/h1_connection.c +++ b/source/h1_connection.c @@ -8,10 +8,8 @@ #include #include #include -#include #include #include -#include #include #include @@ -109,90 +107,13 @@ static const struct aws_h1_decoder_vtable s_h1_decoder_vtable = { .on_done = s_decoder_on_done, }; -struct h1_connection { - struct aws_http_connection base; - - size_t initial_window_size; - - /* Single task used repeatedly for sending data from streams. */ - struct aws_channel_task outgoing_stream_task; - - /* Single task used for issuing window updates from off-thread */ - struct aws_channel_task window_update_task; - - /* Only the event-loop thread may touch this data */ - struct { - /* List of streams being worked on. */ - struct aws_linked_list stream_list; - - /* Points to the stream whose data is currently being sent. - * This stream is ALWAYS in the `stream_list`. - * HTTP pipelining is supported, so once the stream is completely written - * we'll start working on the next stream in the list */ - struct aws_h1_stream *outgoing_stream; - - /* Points to the stream being decoded. - * This stream is ALWAYS in the `stream_list`. */ - struct aws_h1_stream *incoming_stream; - struct aws_h1_decoder *incoming_stream_decoder; - - /* Used to encode requests and responses */ - struct aws_h1_encoder encoder; - - /* Amount to let read-window shrink after a channel message has been processed. */ - size_t incoming_message_window_shrink_size; - - /* Messages received after the connection has switched protocols. - * These are passed downstream to the next handler. */ - struct aws_linked_list midchannel_read_messages; - - /* True when read and/or writing has stopped, whether due to errors or normal channel shutdown. */ - bool is_reading_stopped; - bool is_writing_stopped; - - /* If true, the connection has upgraded to another protocol. - * It will pass data to adjacent channel handlers without altering it. - * The connection can no longer service request/response streams. */ - bool has_switched_protocols; - - /* Server-only. Request-handler streams can only be created while this is true. */ - bool can_create_request_handler_stream; - - struct aws_crt_statistics_http1_channel stats; - - uint64_t outgoing_stream_timestamp_ns; - uint64_t incoming_stream_timestamp_ns; - - } thread_data; - - /* Any thread may touch this data, but the lock must be held */ - struct { - struct aws_mutex lock; - - /* New client streams that have not been moved to `stream_list` yet. - * This list is not used on servers. */ - struct aws_linked_list new_client_stream_list; - - bool is_outgoing_stream_task_active; - - /* For checking status from outside the event-loop thread. */ - bool is_open; - - /* If non-zero, then window_update_task is scheduled */ - size_t window_update_size; - - /* If non-zero, reason to immediately reject new streams. (ex: closing) */ - int new_stream_error_code; - } synced_data; -}; - -static void s_h1_connection_lock_synced_data(struct h1_connection *connection) { +void aws_h1_connection_lock_synced_data(struct aws_h1_connection *connection) { int err = aws_mutex_lock(&connection->synced_data.lock); AWS_ASSERT(!err); (void)err; } -static void s_h1_connection_unlock_synced_data(struct h1_connection *connection) { +void aws_h1_connection_unlock_synced_data(struct aws_h1_connection *connection) { int err = aws_mutex_unlock(&connection->synced_data.lock); AWS_ASSERT(!err); (void)err; @@ -207,7 +128,7 @@ static void s_h1_connection_unlock_synced_data(struct h1_connection *connection) * - User wishes to close the connection (this is the only case where the function may run off-thread). */ static void s_stop( - struct h1_connection *connection, + struct aws_h1_connection *connection, bool stop_reading, bool stop_writing, bool schedule_shutdown, @@ -225,14 +146,14 @@ static void s_stop( connection->thread_data.is_writing_stopped = true; } { /* BEGIN CRITICAL SECTION */ - s_h1_connection_lock_synced_data(connection); + aws_h1_connection_lock_synced_data(connection); /* Even if we're not scheduling shutdown just yet (ex: sent final request but waiting to read final response) * we don't consider the connection "open" anymore so user can't create more streams */ connection->synced_data.is_open = false; connection->synced_data.new_stream_error_code = AWS_ERROR_HTTP_CONNECTION_CLOSED; - s_h1_connection_unlock_synced_data(connection); + aws_h1_connection_unlock_synced_data(connection); } /* END CRITICAL SECTION */ if (schedule_shutdown) { AWS_LOGF_INFO( @@ -246,7 +167,7 @@ static void s_stop( } } -static void s_shutdown_due_to_error(struct h1_connection *connection, int error_code) { +static void s_shutdown_due_to_error(struct aws_h1_connection *connection, int error_code) { AWS_ASSERT(aws_channel_thread_is_callers_thread(connection->base.channel_slot->channel)); if (!error_code) { @@ -267,32 +188,32 @@ static void s_shutdown_due_to_error(struct h1_connection *connection, int error_ * Public function for closing connection. */ static void s_connection_close(struct aws_http_connection *connection_base) { - struct h1_connection *connection = AWS_CONTAINER_OF(connection_base, struct h1_connection, base); + struct aws_h1_connection *connection = AWS_CONTAINER_OF(connection_base, struct aws_h1_connection, base); /* Don't stop reading/writing immediately, let that happen naturally during the channel shutdown process. */ s_stop(connection, false /*stop_reading*/, false /*stop_writing*/, true /*schedule_shutdown*/, AWS_ERROR_SUCCESS); } static bool s_connection_is_open(const struct aws_http_connection *connection_base) { - struct h1_connection *connection = AWS_CONTAINER_OF(connection_base, struct h1_connection, base); + struct aws_h1_connection *connection = AWS_CONTAINER_OF(connection_base, struct aws_h1_connection, base); bool is_open; { /* BEGIN CRITICAL SECTION */ - s_h1_connection_lock_synced_data(connection); + aws_h1_connection_lock_synced_data(connection); is_open = connection->synced_data.is_open; - s_h1_connection_unlock_synced_data(connection); + aws_h1_connection_unlock_synced_data(connection); } /* END CRITICAL SECTION */ return is_open; } static bool s_connection_new_requests_allowed(const struct aws_http_connection *connection_base) { - struct h1_connection *connection = AWS_CONTAINER_OF(connection_base, struct h1_connection, base); + struct aws_h1_connection *connection = AWS_CONTAINER_OF(connection_base, struct aws_h1_connection, base); int new_stream_error_code; { /* BEGIN CRITICAL SECTION */ - s_h1_connection_lock_synced_data(connection); + aws_h1_connection_lock_synced_data(connection); new_stream_error_code = connection->synced_data.new_stream_error_code; - s_h1_connection_unlock_synced_data(connection); + aws_h1_connection_unlock_synced_data(connection); } /* END CRITICAL SECTION */ return new_stream_error_code == 0; } @@ -304,7 +225,7 @@ static int s_stream_send_response(struct aws_http_stream *stream, struct aws_htt int err; int send_err = AWS_ERROR_SUCCESS; struct aws_h1_stream *h1_stream = AWS_CONTAINER_OF(stream, struct aws_h1_stream, base); - struct h1_connection *connection = AWS_CONTAINER_OF(stream->owning_connection, struct h1_connection, base); + struct aws_h1_connection *connection = AWS_CONTAINER_OF(stream->owning_connection, struct aws_h1_connection, base); /* Validate the response and cache info that encoder will eventually need. * The encoder_message object will be moved into the stream later while holding the lock */ @@ -318,7 +239,7 @@ static int s_stream_send_response(struct aws_http_stream *stream, struct aws_htt bool should_schedule_task = false; { /* BEGIN CRITICAL SECTION */ - s_h1_connection_lock_synced_data(connection); + aws_h1_connection_lock_synced_data(connection); if (h1_stream->synced_data.has_outgoing_response) { AWS_LOGF_ERROR(AWS_LS_HTTP_CONNECTION, "id=%p: Response already created on the stream", (void *)stream); send_err = AWS_ERROR_INVALID_STATE; @@ -336,7 +257,7 @@ static int s_stream_send_response(struct aws_http_stream *stream, struct aws_htt should_schedule_task = true; } } - s_h1_connection_unlock_synced_data(connection); + aws_h1_connection_unlock_synced_data(connection); } /* END CRITICAL SECTION */ if (send_err) { @@ -366,7 +287,7 @@ static int s_stream_send_response(struct aws_http_stream *stream, struct aws_htt return AWS_OP_ERR; } -static void s_update_window_action(struct h1_connection *connection, size_t increment_size) { +static void s_update_window_action(struct aws_h1_connection *connection, size_t increment_size) { int err = aws_channel_slot_increment_read_window(connection->base.channel_slot, increment_size); if (err) { AWS_LOGF_ERROR( @@ -381,7 +302,7 @@ static void s_update_window_action(struct h1_connection *connection, size_t incr } static void s_connection_update_window(struct aws_http_connection *connection_base, size_t increment_size) { - struct h1_connection *connection = AWS_CONTAINER_OF(connection_base, struct h1_connection, base); + struct aws_h1_connection *connection = AWS_CONTAINER_OF(connection_base, struct aws_h1_connection, base); if (increment_size == 0) { AWS_LOGF_TRACE(AWS_LS_HTTP_CONNECTION, "id=%p: Ignoring window update of size 0.", (void *)&connection->base); @@ -403,7 +324,7 @@ static void s_connection_update_window(struct aws_http_connection *connection_ba * If task is already scheduled, just increase size to be updated */ /* BEGIN CRITICAL SECTION */ - s_h1_connection_lock_synced_data(connection); + aws_h1_connection_lock_synced_data(connection); /* if this is not volatile, gcc-4x will load window_update_size's address into a register * and then read it as should_schedule_task down below, which will invert its meaning */ @@ -411,7 +332,7 @@ static void s_connection_update_window(struct aws_http_connection *connection_ba connection->synced_data.window_update_size = aws_add_size_saturating(connection->synced_data.window_update_size, increment_size); - s_h1_connection_unlock_synced_data(connection); + aws_h1_connection_unlock_synced_data(connection); /* END CRITICAL SECTION */ if (should_schedule_task) { @@ -435,7 +356,7 @@ int aws_h1_stream_schedule_outgoing_stream_task(struct aws_http_stream *stream) AWS_PRECONDITION(stream); struct aws_http_connection *base_connection = stream->owning_connection; AWS_ASSERT(base_connection); - struct h1_connection *connection = AWS_CONTAINER_OF(base_connection, struct h1_connection, base); + struct aws_h1_connection *connection = AWS_CONTAINER_OF(base_connection, struct aws_h1_connection, base); AWS_ASSERT(connection); AWS_LOGF_TRACE(AWS_LS_HTTP_CONNECTION, "id=%p: Scheduling outgoing stream task.", (void *)&connection->base); aws_channel_schedule_task_now(connection->base.channel_slot->channel, &connection->outgoing_stream_task); @@ -446,23 +367,23 @@ int aws_h1_stream_activate(struct aws_http_stream *stream) { struct aws_h1_stream *h1_stream = AWS_CONTAINER_OF(stream, struct aws_h1_stream, base); struct aws_http_connection *base_connection = stream->owning_connection; - struct h1_connection *connection = AWS_CONTAINER_OF(base_connection, struct h1_connection, base); + struct aws_h1_connection *connection = AWS_CONTAINER_OF(base_connection, struct aws_h1_connection, base); int err; bool should_schedule_task = false; { /* BEGIN CRITICAL SECTION */ - s_h1_connection_lock_synced_data(connection); + aws_h1_connection_lock_synced_data(connection); if (stream->id) { /* stream has already been activated. */ - s_h1_connection_unlock_synced_data(connection); + aws_h1_connection_unlock_synced_data(connection); return AWS_OP_SUCCESS; } err = connection->synced_data.new_stream_error_code; if (err) { - s_h1_connection_unlock_synced_data(connection); + aws_h1_connection_unlock_synced_data(connection); goto error; } @@ -476,7 +397,7 @@ int aws_h1_stream_activate(struct aws_http_stream *stream) { } } - s_h1_connection_unlock_synced_data(connection); + aws_h1_connection_unlock_synced_data(connection); } /* END CRITICAL SECTION */ if (!stream->id) { @@ -520,14 +441,14 @@ struct aws_http_stream *s_make_request( return NULL; } - struct h1_connection *connection = AWS_CONTAINER_OF(client_connection, struct h1_connection, base); + struct aws_h1_connection *connection = AWS_CONTAINER_OF(client_connection, struct aws_h1_connection, base); /* Insert new stream into pending list, and schedule outgoing_stream_task if it's not already running. */ int new_stream_error_code; { /* BEGIN CRITICAL SECTION */ - s_h1_connection_lock_synced_data(connection); + aws_h1_connection_lock_synced_data(connection); new_stream_error_code = connection->synced_data.new_stream_error_code; - s_h1_connection_unlock_synced_data(connection); + aws_h1_connection_unlock_synced_data(connection); } /* END CRITICAL SECTION */ if (new_stream_error_code) { AWS_LOGF_ERROR( @@ -566,14 +487,14 @@ struct aws_http_stream *s_make_request( static void s_update_window_task(struct aws_channel_task *channel_task, void *arg, enum aws_task_status status) { (void)channel_task; - struct h1_connection *connection = arg; + struct aws_h1_connection *connection = arg; if (status != AWS_TASK_STATUS_RUN_READY) { return; } /* BEGIN CRITICAL SECTION */ - s_h1_connection_lock_synced_data(connection); + aws_h1_connection_lock_synced_data(connection); size_t window_update_size = connection->synced_data.window_update_size; AWS_LOGF_TRACE( @@ -583,14 +504,15 @@ static void s_update_window_task(struct aws_channel_task *channel_task, void *ar window_update_size); connection->synced_data.window_update_size = 0; - s_h1_connection_unlock_synced_data(connection); + aws_h1_connection_unlock_synced_data(connection); /* END CRITICAL SECTION */ s_update_window_action(connection, window_update_size); } static void s_stream_complete(struct aws_h1_stream *stream, int error_code) { - struct h1_connection *connection = AWS_CONTAINER_OF(stream->base.owning_connection, struct h1_connection, base); + struct aws_h1_connection *connection = + AWS_CONTAINER_OF(stream->base.owning_connection, struct aws_h1_connection, base); /* Remove stream from list. */ aws_linked_list_remove(&stream->node); @@ -645,7 +567,9 @@ static void s_add_time_measurement_to_stats(uint64_t start_ns, uint64_t end_ns, } } -static void s_set_outgoing_stream_ptr(struct h1_connection *connection, struct aws_h1_stream *next_outgoing_stream) { +static void s_set_outgoing_stream_ptr( + struct aws_h1_connection *connection, + struct aws_h1_stream *next_outgoing_stream) { struct aws_h1_stream *prev = connection->thread_data.outgoing_stream; uint64_t now_ns = 0; @@ -664,7 +588,9 @@ static void s_set_outgoing_stream_ptr(struct h1_connection *connection, struct a connection->thread_data.outgoing_stream = next_outgoing_stream; } -static void s_set_incoming_stream_ptr(struct h1_connection *connection, struct aws_h1_stream *next_incoming_stream) { +static void s_set_incoming_stream_ptr( + struct aws_h1_connection *connection, + struct aws_h1_stream *next_incoming_stream) { struct aws_h1_stream *prev = connection->thread_data.incoming_stream; uint64_t now_ns = 0; @@ -686,7 +612,7 @@ static void s_set_incoming_stream_ptr(struct h1_connection *connection, struct a /** * Ensure `incoming_stream` is pointing at the correct stream, and update state if it changes. */ -static void s_client_update_incoming_stream_ptr(struct h1_connection *connection) { +static void s_client_update_incoming_stream_ptr(struct aws_h1_connection *connection) { struct aws_linked_list *list = &connection->thread_data.stream_list; struct aws_h1_stream *desired; if (connection->thread_data.is_reading_stopped) { @@ -717,7 +643,7 @@ static void s_client_update_incoming_stream_ptr(struct h1_connection *connection * Called from event-loop thread. * This function has lots of side effects. */ -static struct aws_h1_stream *s_update_outgoing_stream_ptr(struct h1_connection *connection) { +static struct aws_h1_stream *s_update_outgoing_stream_ptr(struct aws_h1_connection *connection) { struct aws_h1_stream *current = connection->thread_data.outgoing_stream; bool current_changed = false; int err; @@ -759,7 +685,7 @@ static struct aws_h1_stream *s_update_outgoing_stream_ptr(struct h1_connection * if (!current && !connection->thread_data.is_writing_stopped) { /* ----- BEGIN CRITICAL SECTION ----- */ - s_h1_connection_lock_synced_data(connection); + aws_h1_connection_lock_synced_data(connection); /* Move any streams from new_client_stream_list to stream_list. * NOTE: Can't just swap lists because stream_list might not be empty. */ @@ -799,7 +725,7 @@ static struct aws_h1_stream *s_update_outgoing_stream_ptr(struct h1_connection * connection->synced_data.is_outgoing_stream_task_active = false; } - s_h1_connection_unlock_synced_data(connection); + aws_h1_connection_unlock_synced_data(connection); /* ----- END CRITICAL SECTION ----- */ } @@ -839,7 +765,7 @@ static void s_on_channel_write_complete( void *user_data) { (void)message; - struct h1_connection *connection = user_data; + struct aws_h1_connection *connection = user_data; if (err_code) { AWS_LOGF_TRACE( @@ -875,7 +801,7 @@ static void s_outgoing_stream_task(struct aws_channel_task *task, void *arg, enu return; } - struct h1_connection *connection = arg; + struct aws_h1_connection *connection = arg; struct aws_channel *channel = connection->base.channel_slot->channel; struct aws_io_message *msg = NULL; @@ -974,7 +900,7 @@ static int s_decoder_on_request( const struct aws_byte_cursor *uri, void *user_data) { - struct h1_connection *connection = user_data; + struct aws_h1_connection *connection = user_data; struct aws_h1_stream *incoming_stream = connection->thread_data.incoming_stream; AWS_FATAL_ASSERT(connection->thread_data.incoming_stream->base.server_data); /* Request but I'm a client?!?!? */ @@ -1027,7 +953,7 @@ static int s_decoder_on_request( } static int s_decoder_on_response(int status_code, void *user_data) { - struct h1_connection *connection = user_data; + struct aws_h1_connection *connection = user_data; AWS_FATAL_ASSERT(connection->thread_data.incoming_stream->base.client_data); /* Response but I'm a server?!?!? */ @@ -1045,7 +971,7 @@ static int s_decoder_on_response(int status_code, void *user_data) { } static int s_decoder_on_header(const struct aws_h1_decoded_header *header, void *user_data) { - struct h1_connection *connection = user_data; + struct aws_h1_connection *connection = user_data; struct aws_h1_stream *incoming_stream = connection->thread_data.incoming_stream; AWS_LOGF_TRACE( @@ -1076,9 +1002,9 @@ static int s_decoder_on_header(const struct aws_h1_decoded_header *header, void incoming_stream->is_final_stream = true; { /* BEGIN CRITICAL SECTION */ - s_h1_connection_lock_synced_data(connection); + aws_h1_connection_lock_synced_data(connection); connection->synced_data.new_stream_error_code = AWS_ERROR_HTTP_CONNECTION_CLOSED; - s_h1_connection_unlock_synced_data(connection); + aws_h1_connection_unlock_synced_data(connection); } /* END CRITICAL SECTION */ } } @@ -1113,8 +1039,8 @@ static int s_mark_head_done(struct aws_h1_stream *incoming_stream) { return AWS_OP_SUCCESS; } - struct h1_connection *connection = - AWS_CONTAINER_OF(incoming_stream->base.owning_connection, struct h1_connection, base); + struct aws_h1_connection *connection = + AWS_CONTAINER_OF(incoming_stream->base.owning_connection, struct aws_h1_connection, base); enum aws_http_header_block header_block = aws_h1_decoder_get_header_block(connection->thread_data.incoming_stream_decoder); @@ -1150,9 +1076,9 @@ static int s_mark_head_done(struct aws_h1_stream *incoming_stream) { connection->thread_data.has_switched_protocols = true; { /* BEGIN CRITICAL SECTION */ - s_h1_connection_lock_synced_data(connection); + aws_h1_connection_lock_synced_data(connection); connection->synced_data.new_stream_error_code = AWS_ERROR_HTTP_SWITCHED_PROTOCOLS; - s_h1_connection_unlock_synced_data(connection); + aws_h1_connection_unlock_synced_data(connection); } /* END CRITICAL SECTION */ } } @@ -1179,7 +1105,7 @@ static int s_mark_head_done(struct aws_h1_stream *incoming_stream) { static int s_decoder_on_body(const struct aws_byte_cursor *data, bool finished, void *user_data) { (void)finished; - struct h1_connection *connection = user_data; + struct aws_h1_connection *connection = user_data; struct aws_h1_stream *incoming_stream = connection->thread_data.incoming_stream; AWS_ASSERT(incoming_stream); @@ -1219,7 +1145,7 @@ static int s_decoder_on_body(const struct aws_byte_cursor *data, bool finished, } static int s_decoder_on_done(void *user_data) { - struct h1_connection *connection = user_data; + struct aws_h1_connection *connection = user_data; struct aws_h1_stream *incoming_stream = connection->thread_data.incoming_stream; AWS_ASSERT(incoming_stream); @@ -1288,13 +1214,13 @@ static int s_decoder_on_done(void *user_data) { } /* Common new() logic for server & client */ -static struct h1_connection *s_connection_new( +static struct aws_h1_connection *s_connection_new( struct aws_allocator *alloc, bool manual_window_management, size_t initial_window_size, bool server) { - struct h1_connection *connection = aws_mem_calloc(alloc, 1, sizeof(struct h1_connection)); + struct aws_h1_connection *connection = aws_mem_calloc(alloc, 1, sizeof(struct aws_h1_connection)); if (!connection) { goto error_connection_alloc; } @@ -1371,7 +1297,8 @@ struct aws_http_connection *aws_http_connection_new_http1_1_server( bool manual_window_management, size_t initial_window_size) { - struct h1_connection *connection = s_connection_new(allocator, manual_window_management, initial_window_size, true); + struct aws_h1_connection *connection = + s_connection_new(allocator, manual_window_management, initial_window_size, true); if (!connection) { return NULL; } @@ -1386,7 +1313,7 @@ struct aws_http_connection *aws_http_connection_new_http1_1_client( bool manual_window_management, size_t initial_window_size) { - struct h1_connection *connection = + struct aws_h1_connection *connection = s_connection_new(allocator, manual_window_management, initial_window_size, false); if (!connection) { return NULL; @@ -1398,7 +1325,7 @@ struct aws_http_connection *aws_http_connection_new_http1_1_client( } static void s_handler_destroy(struct aws_channel_handler *handler) { - struct h1_connection *connection = handler->impl; + struct aws_h1_connection *connection = handler->impl; AWS_LOGF_TRACE(AWS_LS_HTTP_CONNECTION, "id=%p: Destroying connection.", (void *)&connection->base); @@ -1413,7 +1340,7 @@ static void s_handler_destroy(struct aws_channel_handler *handler) { } static void s_handler_installed(struct aws_channel_handler *handler, struct aws_channel_slot *slot) { - struct h1_connection *connection = handler->impl; + struct aws_h1_connection *connection = handler->impl; connection->base.channel_slot = slot; /* Acquire a hold on the channel to prevent its destruction until the user has @@ -1421,7 +1348,7 @@ static void s_handler_installed(struct aws_channel_handler *handler, struct aws_ aws_channel_acquire_hold(slot->channel); } -static void s_connection_try_send_read_messages(struct h1_connection *connection) { +static void s_connection_try_send_read_messages(struct aws_h1_connection *connection) { AWS_ASSERT(aws_channel_thread_is_callers_thread(connection->base.channel_slot->channel)); AWS_ASSERT(connection->thread_data.has_switched_protocols); AWS_ASSERT(!connection->thread_data.is_reading_stopped); @@ -1520,7 +1447,7 @@ static void s_connection_try_send_read_messages(struct h1_connection *connection static struct aws_http_stream *s_new_server_request_handler_stream( const struct aws_http_request_handler_options *options) { - struct h1_connection *connection = AWS_CONTAINER_OF(options->server_connection, struct h1_connection, base); + struct aws_h1_connection *connection = AWS_CONTAINER_OF(options->server_connection, struct aws_h1_connection, base); if (!aws_channel_thread_is_callers_thread(connection->base.channel_slot->channel) || !connection->thread_data.can_create_request_handler_stream) { @@ -1570,7 +1497,7 @@ static struct aws_http_stream *s_new_server_request_handler_stream( } /* Invokes the on_incoming_request callback and returns new stream. */ -static struct aws_h1_stream *s_server_invoke_on_incoming_request(struct h1_connection *connection) { +static struct aws_h1_stream *s_server_invoke_on_incoming_request(struct aws_h1_connection *connection) { AWS_PRECONDITION(connection->base.server_data); AWS_PRECONDITION(aws_channel_thread_is_callers_thread(connection->base.channel_slot->channel)); AWS_PRECONDITION(!connection->thread_data.can_create_request_handler_stream); @@ -1594,7 +1521,7 @@ static int s_handler_process_read_message( struct aws_channel_slot *slot, struct aws_io_message *message) { - struct h1_connection *connection = handler->impl; + struct aws_h1_connection *connection = handler->impl; int err; const size_t incoming_message_size = message->message_data.len; @@ -1742,7 +1669,7 @@ static int s_handler_process_write_message( struct aws_channel_slot *slot, struct aws_io_message *message) { - struct h1_connection *connection = handler->impl; + struct aws_h1_connection *connection = handler->impl; if (connection->thread_data.is_writing_stopped) { aws_raise_error(AWS_ERROR_HTTP_CONNECTION_CLOSED); @@ -1783,7 +1710,7 @@ static int s_handler_increment_read_window( struct aws_channel_slot *slot, size_t size) { - struct h1_connection *connection = handler->impl; + struct aws_h1_connection *connection = handler->impl; if (connection->thread_data.is_reading_stopped) { aws_raise_error(AWS_ERROR_HTTP_CONNECTION_CLOSED); @@ -1827,7 +1754,7 @@ static int s_handler_shutdown( bool free_scarce_resources_immediately) { (void)free_scarce_resources_immediately; - struct h1_connection *connection = handler->impl; + struct aws_h1_connection *connection = handler->impl; AWS_LOGF_TRACE( AWS_LS_HTTP_CONNECTION, @@ -1873,7 +1800,7 @@ static int s_handler_shutdown( } static size_t s_handler_initial_window_size(struct aws_channel_handler *handler) { - struct h1_connection *connection = handler->impl; + struct aws_h1_connection *connection = handler->impl; return connection->initial_window_size; } @@ -1883,12 +1810,12 @@ static size_t s_handler_message_overhead(struct aws_channel_handler *handler) { } static void s_reset_statistics(struct aws_channel_handler *handler) { - struct h1_connection *connection = handler->impl; + struct aws_h1_connection *connection = handler->impl; aws_crt_statistics_http1_channel_reset(&connection->thread_data.stats); } -static void s_pull_up_stats_timestamps(struct h1_connection *connection) { +static void s_pull_up_stats_timestamps(struct aws_h1_connection *connection) { uint64_t now_ns = 0; if (aws_channel_current_clock_time(connection->base.channel_slot->channel, &now_ns)) { return; @@ -1920,7 +1847,7 @@ static void s_pull_up_stats_timestamps(struct h1_connection *connection) { } static void s_gather_statistics(struct aws_channel_handler *handler, struct aws_array_list *stats) { - struct h1_connection *connection = handler->impl; + struct aws_h1_connection *connection = handler->impl; s_pull_up_stats_timestamps(connection); @@ -1931,7 +1858,7 @@ static void s_gather_statistics(struct aws_channel_handler *handler, struct aws_ struct aws_crt_statistics_http1_channel *aws_h1_connection_get_statistics(struct aws_http_connection *connection) { AWS_ASSERT(aws_channel_thread_is_callers_thread(connection->channel_slot->channel)); - struct h1_connection *h1_conn = (void *)connection; + struct aws_h1_connection *h1_conn = (void *)connection; return &h1_conn->thread_data.stats; }