From c9e80fb26a0b9325f06da3e5827db17c85dc2efe Mon Sep 17 00:00:00 2001 From: klempner Date: Wed, 10 Dec 2014 17:00:16 -0800 Subject: Patch shutdown during write test to not fail or do a racy destroy if the write completes successfully. Change on 2014/12/10 by klempner ------------- Created by MOE: http://code.google.com/p/moe-java MOE_MIGRATED_REVID=81831655 --- test/core/endpoint/endpoint_tests.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'test') diff --git a/test/core/endpoint/endpoint_tests.c b/test/core/endpoint/endpoint_tests.c index 50919fc45e..8b95d6159b 100644 --- a/test/core/endpoint/endpoint_tests.c +++ b/test/core/endpoint/endpoint_tests.c @@ -368,8 +368,14 @@ static void shutdown_during_write_test_write_handler( shutdown_during_write_test_state *st = user_data; gpr_log(GPR_INFO, "shutdown_during_write_test_write_handler: error = %d", error); - grpc_endpoint_destroy(st->ep); - gpr_event_set(&st->ev, (void *)(gpr_intptr)error); + if (error == 0) { + /* This happens about 0.5% of the time when run under TSAN, and is entirely + legitimate, but means we aren't testing the path we think we are. */ + /* TODO(klempner): Change this test to retry the write in that case */ + gpr_log(GPR_ERROR, + "shutdown_during_write_test_write_handler completed unexpectedly"); + } + gpr_event_set(&st->ev, (void *)(gpr_intptr)1); } static void shutdown_during_write_test(grpc_endpoint_test_config config, @@ -391,11 +397,6 @@ static void shutdown_during_write_test(grpc_endpoint_test_config config, gpr_event_init(&read_st.ev); gpr_event_init(&write_st.ev); -#if 0 - read_st.ep = grpc_tcp_create(sv[1], &em); - write_st.ep = grpc_tcp_create(sv[0], &em); -#endif - grpc_endpoint_notify_on_read(read_st.ep, shutdown_during_write_test_read_handler, &read_st, gpr_inf_future); @@ -414,6 +415,7 @@ static void shutdown_during_write_test(grpc_endpoint_test_config config, deadline = gpr_time_add(gpr_now(), gpr_time_from_micros(10 * GPR_US_PER_SEC)); GPR_ASSERT(gpr_event_wait(&write_st.ev, deadline)); + grpc_endpoint_destroy(write_st.ep); GPR_ASSERT(gpr_event_wait(&read_st.ev, deadline)); gpr_free(slices); end_test(config); -- cgit v1.2.3