@@ -43,6 +43,12 @@ struct aws_h2_sm_connection {
4343 } thread_data ;
4444
4545 enum aws_h2_sm_connection_state_type state ;
46+
47+ /**
48+ * Node for tracking in the all_held_connections list,
49+ * NOTE: lock required to alter the state of the list.
50+ */
51+ struct aws_linked_list_node node ;
4652};
4753
4854/* Live from the user request to acquire a stream to the stream completed. */
@@ -114,6 +120,14 @@ struct aws_http2_stream_manager {
114120 */
115121 size_t max_concurrent_streams_per_connection ;
116122
123+ /**
124+ * Optional. 0 means no limit (default).
125+ * The max number of concurrent streams that can be active across all connections at the same time.
126+ * When this limit is reached, the stream manager will wait for existing streams to complete
127+ * before creating new ones, even if connections have available capacity.
128+ */
129+ size_t max_concurrent_streams ;
130+
117131 /**
118132 * Task to invoke pending acquisition callbacks asynchronously if stream manager is shutting.
119133 */
@@ -129,26 +143,36 @@ struct aws_http2_stream_manager {
129143 enum aws_h2_sm_state_type state ;
130144
131145 /**
132- * A set of all connections that meet all requirement to use. Note: there will be connections not in this set,
133- * but hold by the stream manager, which can be tracked by the streams created on it. Set of `struct
134- * aws_h2_sm_connection *`
146+ * A set of all connections that meet all requirement to use. Doesn't own the connection.
147+ *
148+ * Note: there will be connections not in this set, but hold by the stream manager, which can be tracked by the
149+ * all_held_connections. Set of `struct aws_h2_sm_connection *`
135150 */
136151 struct aws_random_access_set ideal_available_set ;
137152 /**
138- * A set of all available connections that exceed the soft limits set by users. Note: there will be connections
139- * not in this set, but hold by the stream manager, which can be tracked by the streams created. Set of `struct
140- * aws_h2_sm_connection *`
153+ * A set of all available connections that exceed the soft limits set by users. Doesn't own the connection.
154+ *
155+ * Note: there will be connections not in this set, but hold by the stream manager, which can be tracked by the
156+ * all_held_connections. Set of `struct aws_h2_sm_connection *`
141157 */
142158 struct aws_random_access_set nonideal_available_set ;
143- /* We don't mantain set for connections that is full or "dead" (Cannot make any new streams). We have streams
144- * opening from the connection tracking them */
159+ /* We don't mantain set for connections that is full or "dead" (Cannot make any new streams). We have
160+ * all_held_connections tracking them */
145161
146162 /**
147163 * The set of all incomplete stream acquisition requests (haven't decide what connection to make the request
148164 * to), list of `struct aws_h2_sm_pending_stream_acquisition*`
149165 */
150166 struct aws_linked_list pending_stream_acquisitions ;
151167
168+ /**
169+ * List of all aws_h2_sm_connection that holding the HTTP connection from connection manager.
170+ * This list tracks all aws_h2_sm_connection from getting the connection from connection manager until release
171+ * it back.
172+ * list of `struct aws_h2_sm_connection*`
173+ */
174+ struct aws_linked_list all_held_connections ;
175+
152176 /**
153177 * The number of connections acquired from connection manager and not released yet.
154178 */
0 commit comments