@@ -74,6 +74,7 @@ struct tester {
74
74
int server_connection_is_shutdown ;
75
75
int wait_client_connection_is_shutdown ;
76
76
int wait_server_connection_is_shutdown ;
77
+ bool client_bootstrap_is_shutdown ;
77
78
78
79
bool server_is_shutdown ;
79
80
struct aws_http_connection * new_client_connection ;
@@ -186,6 +187,15 @@ static void s_tester_on_client_connection_shutdown(
186
187
AWS_FATAL_ASSERT (aws_mutex_unlock (& tester -> wait_lock ) == AWS_OP_SUCCESS );
187
188
aws_condition_variable_notify_one (& tester -> wait_cvar );
188
189
}
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
+ }
189
199
190
200
static int s_tester_wait (struct tester * tester , bool (* pred )(void * user_data )) {
191
201
int local_wait_result ;
@@ -230,6 +240,11 @@ static bool s_tester_server_shutdown_pred(void *user_data) {
230
240
return tester -> server_is_shutdown ;
231
241
}
232
242
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
+
233
248
static int s_tester_init (struct tester * tester , const struct tester_options * options ) {
234
249
AWS_ZERO_STRUCT (* tester );
235
250
@@ -289,8 +304,13 @@ static int s_tester_init(struct tester *tester, const struct tester_options *opt
289
304
return AWS_OP_SUCCESS ;
290
305
}
291
306
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 );
294
314
ASSERT_NOT_NULL (tester -> client_bootstrap );
295
315
296
316
/* Connect */
@@ -377,6 +397,7 @@ static int s_test_connection_setup_shutdown(struct aws_allocator *allocator, voi
377
397
ASSERT_SUCCESS (s_tester_wait (& tester , s_tester_connection_shutdown_pred ));
378
398
379
399
aws_client_bootstrap_release (tester .client_bootstrap );
400
+ ASSERT_SUCCESS (s_tester_wait (& tester , s_tester_client_bootstrap_shutdown_pred ));
380
401
381
402
ASSERT_SUCCESS (s_tester_clean_up (& tester ));
382
403
return AWS_OP_SUCCESS ;
@@ -403,6 +424,7 @@ static int s_test_connection_destroy_server_with_connection_existing(struct aws_
403
424
release_all_client_connections (& tester );
404
425
release_all_server_connections (& tester );
405
426
aws_client_bootstrap_release (tester .client_bootstrap );
427
+ ASSERT_SUCCESS (s_tester_wait (& tester , s_tester_client_bootstrap_shutdown_pred ));
406
428
407
429
ASSERT_SUCCESS (s_tester_clean_up (& tester ));
408
430
return AWS_OP_SUCCESS ;
@@ -445,7 +467,10 @@ static int s_test_connection_destroy_server_with_multiple_connections_existing(
445
467
/* release memory */
446
468
release_all_client_connections (& tester );
447
469
release_all_server_connections (& tester );
470
+
448
471
aws_client_bootstrap_release (tester .client_bootstrap );
472
+ ASSERT_SUCCESS (s_tester_wait (& tester , s_tester_client_bootstrap_shutdown_pred ));
473
+
449
474
ASSERT_SUCCESS (s_tester_clean_up (& tester ));
450
475
return AWS_OP_SUCCESS ;
451
476
}
@@ -541,8 +566,11 @@ static int s_test_connection_server_shutting_down_new_connection_setup_fail(
541
566
aws_task_init (server_block_task , s_block_task , & tester , "wait_a_bit" );
542
567
aws_event_loop_schedule_task_now (server_eventloop , server_block_task );
543
568
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 );
546
574
struct aws_http_client_connection_options client_options = AWS_HTTP_CLIENT_CONNECTION_OPTIONS_INIT ;
547
575
client_options .allocator = tester .alloc ;
548
576
client_options .bootstrap = bootstrap ;
@@ -580,8 +608,9 @@ static int s_test_connection_server_shutting_down_new_connection_setup_fail(
580
608
/* release memory */
581
609
release_all_client_connections (& tester );
582
610
release_all_server_connections (& tester );
583
- aws_client_bootstrap_release (tester .client_bootstrap );
584
611
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 ));
585
614
aws_event_loop_group_clean_up (& event_loop_group );
586
615
ASSERT_SUCCESS (s_tester_clean_up (& tester ));
587
616
0 commit comments