|
|
|
@ -96,14 +96,16 @@ class TestServiceImpl : public ::grpc::cpp::test::util::TestService::Service { |
|
|
|
|
signal_client_ = true; |
|
|
|
|
} |
|
|
|
|
while (!context->IsCancelled()) { |
|
|
|
|
std::this_thread::sleep_for(std::chrono::microseconds( |
|
|
|
|
request->param().client_cancel_after_us())); |
|
|
|
|
gpr_sleep_until(gpr_time_add( |
|
|
|
|
gpr_now(), |
|
|
|
|
gpr_time_from_micros(request->param().client_cancel_after_us()))); |
|
|
|
|
} |
|
|
|
|
return Status::Cancelled; |
|
|
|
|
} else if (request->has_param() && |
|
|
|
|
request->param().server_cancel_after_us()) { |
|
|
|
|
std::this_thread::sleep_for( |
|
|
|
|
std::chrono::microseconds(request->param().server_cancel_after_us())); |
|
|
|
|
gpr_sleep_until(gpr_time_add( |
|
|
|
|
gpr_now(), |
|
|
|
|
gpr_time_from_micros(request->param().server_cancel_after_us()))); |
|
|
|
|
return Status::Cancelled; |
|
|
|
|
} else { |
|
|
|
|
EXPECT_FALSE(context->IsCancelled()); |
|
|
|
@ -469,7 +471,7 @@ TEST_F(End2endTest, BadCredentials) { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void CancelRpc(ClientContext* context, int delay_us, TestServiceImpl* service) { |
|
|
|
|
std::this_thread::sleep_for(std::chrono::microseconds(delay_us)); |
|
|
|
|
gpr_sleep_until(gpr_time_add(gpr_now(), gpr_time_from_micros(delay_us))); |
|
|
|
|
while (!service->signal_client()) { |
|
|
|
|
} |
|
|
|
|
context->TryCancel(); |
|
|
|
|