From 83ad85e2faa0e980ed51b1979c4e6486ec1afd3b Mon Sep 17 00:00:00 2001 From: Yash Tibrewal Date: Tue, 30 Jan 2018 15:25:05 -0800 Subject: Remove unnecessary check and few more comments --- test/core/bad_client/bad_client.cc | 10 +++++----- test/core/bad_client/bad_client.h | 4 ++++ 2 files changed, 9 insertions(+), 5 deletions(-) (limited to 'test/core/bad_client') diff --git a/test/core/bad_client/bad_client.cc b/test/core/bad_client/bad_client.cc index 6a35ffcb6d..df803d16a2 100644 --- a/test/core/bad_client/bad_client.cc +++ b/test/core/bad_client/bad_client.cc @@ -153,8 +153,7 @@ void grpc_run_client_side_validator(grpc_bad_client_arg* arg, uint32_t flags, client_cq, grpc_timeout_milliseconds_to_deadline(100), nullptr) .type == GRPC_QUEUE_TIMEOUT); - } while (!gpr_event_get(&read_done_event) || - !gpr_event_get(&done_write)); + } while (!gpr_event_get(&read_done_event)); if (arg->client_validator(&incoming, arg->client_validator_arg)) break; gpr_log(GPR_INFO, "client validator failed; trying additional read " @@ -165,12 +164,13 @@ void grpc_run_client_side_validator(grpc_bad_client_arg* arg, uint32_t flags, grpc_core::ExecCtx::Get()->Flush(); } - /* If flags is non-zero, it is time to shutdown the client */ - if (flags) { + /* If the request was too large, then we need to forcefully shut down the + * client, so that the write can be considered completed */ + if (flags & GRPC_BAD_CLIENT_LARGE_REQUEST) { shutdown_client(&sfd->client); } - /* Make sure that the server is done writing */ + /* Make sure that the client is done writing */ while (!gpr_event_get(&done_write)) { GPR_ASSERT( grpc_completion_queue_next( diff --git a/test/core/bad_client/bad_client.h b/test/core/bad_client/bad_client.h index 46f25269ca..de7d830cd7 100644 --- a/test/core/bad_client/bad_client.h +++ b/test/core/bad_client/bad_client.h @@ -44,6 +44,7 @@ struct grpc_bad_client_arg { size_t client_payload_length; }; +/* Flags for grpc_run_bad_client_test */ #define GRPC_BAD_CLIENT_DISCONNECT 1 #define GRPC_BAD_CLIENT_LARGE_REQUEST 2 @@ -53,6 +54,9 @@ struct grpc_bad_client_arg { * payload, run client_validator to make sure that the response is as expected. * Also execute \a server_validator in a separate thread to assert that the * bytes are handled as expected. + * + * The flags are only applicable to the last validator in the array. (This can + * be changed in the future if necessary) */ void grpc_run_bad_client_test( grpc_bad_client_server_side_validator server_validator, -- cgit v1.2.3