Skip to content

Async streams for HTTP#547

Draft
azkrishpy wants to merge 5 commits intomainfrom
expose-async
Draft

Async streams for HTTP#547
azkrishpy wants to merge 5 commits intomainfrom
expose-async

Conversation

@azkrishpy
Copy link
Contributor

Issue #, if available:

Description of changes:

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

Comment on lines +887 to +888
* Note: The message does NOT take ownership of the body stream.
* The stream must not be destroyed until the message is complete.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should, and the same comments for aws_http_message_set_body_stream is actually out dated, that I forgot to remove.

So, the input streams are refcounted, so that we should keep a refcount on it with the http message.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to make the design easier to use, let's say it's an error to set both. you can only set either one of the regular body stream or the async body stream


bool is_processing_read_messages : 1;

struct aws_io_message *pending_async_message;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

comment on what does this do?

Comment on lines +1135 to +1139
if (msg) {
aws_mem_release(msg->allocator, msg);
}
s_shutdown_due_to_error(connection, connection->thread_data.encoder.async_error);
return;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

trivial: seems like we can just goto error, with a aws_raise_error(connection->thread_data.encoder.async_error)

Comment on lines +1034 to +1035
/* If encoder is waiting for async body read, don't reschedule - the async callback will do it */
if (connection->thread_data.encoder.state == AWS_H1_ENCODER_STATE_ASYNC_WAITING) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the connection is a user of the encoder, so it is better to not know the implementation detail of the encoder.

It's better to have a helper function to check if encoder is waiting for data async, instead of just querying the state of the encoder.

Comment on lines +1596 to +1597
/* hacking around with adding connection to encoder. there should be a better way to do it */
connection->thread_data.encoder.connection = connection;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the better way to decouple them is probably expose something like

aws_encoder_set_async_stream_read_done(callback, user_data);

So that we keep the logic of handling the stream read done within the connection instead of the encoder

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants