@@ -74,6 +74,7 @@ struct tester {
7474 int server_connection_is_shutdown ;
7575 int wait_client_connection_is_shutdown ;
7676 int wait_server_connection_is_shutdown ;
77+ bool client_bootstrap_is_shutdown ;
7778
7879 bool server_is_shutdown ;
7980 struct aws_http_connection * new_client_connection ;
@@ -186,6 +187,15 @@ static void s_tester_on_client_connection_shutdown(
186187 AWS_FATAL_ASSERT (aws_mutex_unlock (& tester -> wait_lock ) == AWS_OP_SUCCESS );
187188 aws_condition_variable_notify_one (& tester -> wait_cvar );
188189}
190+ static void s_tester_on_client_bootstrap_shutdown (void * user_data ) {
191+ struct tester * tester = user_data ;
192+ AWS_FATAL_ASSERT (aws_mutex_lock (& tester -> wait_lock ) == AWS_OP_SUCCESS );
193+
194+ tester -> client_bootstrap_is_shutdown = true;
195+
196+ AWS_FATAL_ASSERT (aws_mutex_unlock (& tester -> wait_lock ) == AWS_OP_SUCCESS );
197+ aws_condition_variable_notify_one (& tester -> wait_cvar );
198+ }
189199
190200static int s_tester_wait (struct tester * tester , bool (* pred )(void * user_data )) {
191201 int local_wait_result ;
@@ -230,6 +240,11 @@ static bool s_tester_server_shutdown_pred(void *user_data) {
230240 return tester -> server_is_shutdown ;
231241}
232242
243+ static bool s_tester_client_bootstrap_shutdown_pred (void * user_data ) {
244+ struct tester * tester = user_data ;
245+ return tester -> client_bootstrap_is_shutdown ;
246+ }
247+
233248static int s_tester_init (struct tester * tester , const struct tester_options * options ) {
234249 AWS_ZERO_STRUCT (* tester );
235250
@@ -289,8 +304,13 @@ static int s_tester_init(struct tester *tester, const struct tester_options *opt
289304 return AWS_OP_SUCCESS ;
290305 }
291306
292- tester -> client_bootstrap =
293- aws_client_bootstrap_new (tester -> alloc , & tester -> event_loop_group , & tester -> host_resolver , NULL );
307+ struct aws_client_bootstrap_options bootstrap_options = {
308+ .event_loop_group = & tester -> event_loop_group ,
309+ .host_resolver = & tester -> host_resolver ,
310+ .on_shutdown_complete = s_tester_on_client_bootstrap_shutdown ,
311+ .user_data = tester ,
312+ };
313+ tester -> client_bootstrap = aws_client_bootstrap_new (tester -> alloc , & bootstrap_options );
294314 ASSERT_NOT_NULL (tester -> client_bootstrap );
295315
296316 /* Connect */
@@ -377,6 +397,7 @@ static int s_test_connection_setup_shutdown(struct aws_allocator *allocator, voi
377397 ASSERT_SUCCESS (s_tester_wait (& tester , s_tester_connection_shutdown_pred ));
378398
379399 aws_client_bootstrap_release (tester .client_bootstrap );
400+ ASSERT_SUCCESS (s_tester_wait (& tester , s_tester_client_bootstrap_shutdown_pred ));
380401
381402 ASSERT_SUCCESS (s_tester_clean_up (& tester ));
382403 return AWS_OP_SUCCESS ;
@@ -403,6 +424,7 @@ static int s_test_connection_destroy_server_with_connection_existing(struct aws_
403424 release_all_client_connections (& tester );
404425 release_all_server_connections (& tester );
405426 aws_client_bootstrap_release (tester .client_bootstrap );
427+ ASSERT_SUCCESS (s_tester_wait (& tester , s_tester_client_bootstrap_shutdown_pred ));
406428
407429 ASSERT_SUCCESS (s_tester_clean_up (& tester ));
408430 return AWS_OP_SUCCESS ;
@@ -445,7 +467,10 @@ static int s_test_connection_destroy_server_with_multiple_connections_existing(
445467 /* release memory */
446468 release_all_client_connections (& tester );
447469 release_all_server_connections (& tester );
470+
448471 aws_client_bootstrap_release (tester .client_bootstrap );
472+ ASSERT_SUCCESS (s_tester_wait (& tester , s_tester_client_bootstrap_shutdown_pred ));
473+
449474 ASSERT_SUCCESS (s_tester_clean_up (& tester ));
450475 return AWS_OP_SUCCESS ;
451476}
@@ -541,8 +566,11 @@ static int s_test_connection_server_shutting_down_new_connection_setup_fail(
541566 aws_task_init (server_block_task , s_block_task , & tester , "wait_a_bit" );
542567 aws_event_loop_schedule_task_now (server_eventloop , server_block_task );
543568
544- struct aws_client_bootstrap * bootstrap =
545- aws_client_bootstrap_new (allocator , & event_loop_group , & tester .host_resolver , NULL );
569+ struct aws_client_bootstrap_options bootstrap_options = {
570+ .event_loop_group = & event_loop_group ,
571+ .host_resolver = & tester .host_resolver ,
572+ };
573+ struct aws_client_bootstrap * bootstrap = aws_client_bootstrap_new (allocator , & bootstrap_options );
546574 struct aws_http_client_connection_options client_options = AWS_HTTP_CLIENT_CONNECTION_OPTIONS_INIT ;
547575 client_options .allocator = tester .alloc ;
548576 client_options .bootstrap = bootstrap ;
@@ -580,8 +608,9 @@ static int s_test_connection_server_shutting_down_new_connection_setup_fail(
580608 /* release memory */
581609 release_all_client_connections (& tester );
582610 release_all_server_connections (& tester );
583- aws_client_bootstrap_release (tester .client_bootstrap );
584611 aws_client_bootstrap_release (bootstrap );
612+ aws_client_bootstrap_release (tester .client_bootstrap );
613+ ASSERT_SUCCESS (s_tester_wait (& tester , s_tester_client_bootstrap_shutdown_pred ));
585614 aws_event_loop_group_clean_up (& event_loop_group );
586615 ASSERT_SUCCESS (s_tester_clean_up (& tester ));
587616
0 commit comments