Skip to content

Commit b53100e

Browse files
authored
move h1_connection struct to private .h file (#273)
rename `h1_connection` -> `aws_h1_connection` Doing this so it's easier to share code between h1_connection.c/h1_stream.c. This is part of a larger change, but it's so disruptive I'm breaking it out into its own PR. This is similar to how we do it for h2, so that's nice too.
1 parent f7da123 commit b53100e

File tree

2 files changed

+160
-149
lines changed

2 files changed

+160
-149
lines changed

include/aws/http/private/h1_connection.h

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,85 @@
77
*/
88

99
#include <aws/http/private/connection_impl.h>
10+
#include <aws/http/private/h1_encoder.h>
11+
#include <aws/http/statistics.h>
12+
13+
struct aws_h1_connection {
14+
struct aws_http_connection base;
15+
16+
size_t initial_window_size;
17+
18+
/* Single task used repeatedly for sending data from streams. */
19+
struct aws_channel_task outgoing_stream_task;
20+
21+
/* Single task used for issuing window updates from off-thread */
22+
struct aws_channel_task window_update_task;
23+
24+
/* Only the event-loop thread may touch this data */
25+
struct {
26+
/* List of streams being worked on. */
27+
struct aws_linked_list stream_list;
28+
29+
/* Points to the stream whose data is currently being sent.
30+
* This stream is ALWAYS in the `stream_list`.
31+
* HTTP pipelining is supported, so once the stream is completely written
32+
* we'll start working on the next stream in the list */
33+
struct aws_h1_stream *outgoing_stream;
34+
35+
/* Points to the stream being decoded.
36+
* This stream is ALWAYS in the `stream_list`. */
37+
struct aws_h1_stream *incoming_stream;
38+
struct aws_h1_decoder *incoming_stream_decoder;
39+
40+
/* Used to encode requests and responses */
41+
struct aws_h1_encoder encoder;
42+
43+
/* Amount to let read-window shrink after a channel message has been processed. */
44+
size_t incoming_message_window_shrink_size;
45+
46+
/* Messages received after the connection has switched protocols.
47+
* These are passed downstream to the next handler. */
48+
struct aws_linked_list midchannel_read_messages;
49+
50+
/* True when read and/or writing has stopped, whether due to errors or normal channel shutdown. */
51+
bool is_reading_stopped;
52+
bool is_writing_stopped;
53+
54+
/* If true, the connection has upgraded to another protocol.
55+
* It will pass data to adjacent channel handlers without altering it.
56+
* The connection can no longer service request/response streams. */
57+
bool has_switched_protocols;
58+
59+
/* Server-only. Request-handler streams can only be created while this is true. */
60+
bool can_create_request_handler_stream;
61+
62+
struct aws_crt_statistics_http1_channel stats;
63+
64+
uint64_t outgoing_stream_timestamp_ns;
65+
uint64_t incoming_stream_timestamp_ns;
66+
67+
} thread_data;
68+
69+
/* Any thread may touch this data, but the lock must be held */
70+
struct {
71+
struct aws_mutex lock;
72+
73+
/* New client streams that have not been moved to `stream_list` yet.
74+
* This list is not used on servers. */
75+
struct aws_linked_list new_client_stream_list;
76+
77+
bool is_outgoing_stream_task_active;
78+
79+
/* For checking status from outside the event-loop thread. */
80+
bool is_open;
81+
82+
/* If non-zero, then window_update_task is scheduled */
83+
size_t window_update_size;
84+
85+
/* If non-zero, reason to immediately reject new streams. (ex: closing) */
86+
int new_stream_error_code;
87+
} synced_data;
88+
};
1089

1190
AWS_EXTERN_C_BEGIN
1291

@@ -24,4 +103,9 @@ struct aws_http_connection *aws_http_connection_new_http1_1_client(
24103

25104
AWS_EXTERN_C_END
26105

106+
/* DO NOT export functions below. They're used by other .c files in this library */
107+
108+
void aws_h1_connection_lock_synced_data(struct aws_h1_connection *connection);
109+
void aws_h1_connection_unlock_synced_data(struct aws_h1_connection *connection);
110+
27111
#endif /* AWS_HTTP_H1_CONNECTION_H */

0 commit comments

Comments
 (0)