diff options
author | klempner <klempner@google.com> | 2014-12-10 17:00:16 -0800 |
---|---|---|
committer | Jan Tattermusch <jtattermusch@google.com> | 2014-12-11 15:11:44 -0800 |
commit | c9e80fb26a0b9325f06da3e5827db17c85dc2efe (patch) | |
tree | 02fad5363cd4e16d1f2b40b64e690591112c5d73 | |
parent | ebebb7e21c976b5887a24795cf1435bed58a2906 (diff) |
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 <klempner@google.com>
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=81831655
-rw-r--r-- | test/core/endpoint/endpoint_tests.c | 16 |
1 files changed, 9 insertions, 7 deletions
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); |