Fix tsan reported error
diff --git a/test/core/client_config/set_initial_connect_string_test.c b/test/core/client_config/set_initial_connect_string_test.c
index 5b7f222..c1b8452 100644
--- a/test/core/client_config/set_initial_connect_string_test.c
+++ b/test/core/client_config/set_initial_connect_string_test.c
@@ -57,7 +57,7 @@
gpr_slice_buffer incoming_buffer;
gpr_slice_buffer temp_incoming_buffer;
grpc_endpoint *tcp;
- int done;
+ gpr_atm done_atm;
};
static const char *magic_connect_string = "magic initial string";
@@ -70,7 +70,7 @@
gpr_slice_buffer_move_into(&state.temp_incoming_buffer,
&state.incoming_buffer);
if (state.incoming_buffer.length > strlen(magic_connect_string)) {
- state.done = 1;
+ gpr_atm_rel_store(&state.done_atm, 1);
grpc_endpoint_shutdown(exec_ctx, state.tcp);
grpc_endpoint_destroy(exec_ctx, state.tcp);
} else {
@@ -117,7 +117,7 @@
}
static void start_rpc(int use_creds, int target_port) {
- state.done = 0;
+ gpr_atm_rel_store(&state.done_atm, 0);
state.cq = grpc_completion_queue_create(NULL);
if (use_creds) {
state.creds = grpc_fake_transport_security_credentials_create();
@@ -166,7 +166,7 @@
static void actually_poll_server(void *arg) {
poll_args *pa = arg;
gpr_timespec deadline = n_sec_deadline(10);
- while (state.done == 0 &&
+ while (gpr_atm_acq_load(&state.done_atm) == 0 &&
gpr_time_cmp(gpr_now(GPR_CLOCK_REALTIME), deadline) < 0) {
test_tcp_server_poll(pa->server, 1);
}