[e2e] Fix failure in thready_tsan for cancel_before_invoke with v3 (#36955)

We should only start a call if we're going to use that call (which means not if the call is already cancelled!)

Closes #36955

COPYBARA_INTEGRATE_REVIEW=https://github.com/grpc/grpc/pull/36955 from ctiller:flakezzzz 2368338bf6
PiperOrigin-RevId: 644171653
pull/36960/head
Craig Tiller 5 months ago committed by Copybara-Service
parent 1071ada87c
commit bc26f27c32
  1. 5
      src/core/lib/surface/client_call.cc

@ -231,13 +231,15 @@ void ClientCall::StartCall(const grpc_op& send_initial_metadata_op) {
auto call = MakeCallPair(std::move(send_initial_metadata_), event_engine(), auto call = MakeCallPair(std::move(send_initial_metadata_), event_engine(),
arena()->Ref()); arena()->Ref());
started_call_initiator_ = std::move(call.initiator); started_call_initiator_ = std::move(call.initiator);
call_destination_->StartCall(std::move(call.handler));
while (true) { while (true) {
GRPC_TRACE_LOG(call, INFO)
<< DebugTag() << "StartCall " << GRPC_DUMP_ARGS(cur_state);
switch (cur_state) { switch (cur_state) {
case kUnstarted: case kUnstarted:
if (call_state_.compare_exchange_strong(cur_state, kStarted, if (call_state_.compare_exchange_strong(cur_state, kStarted,
std::memory_order_acq_rel, std::memory_order_acq_rel,
std::memory_order_acquire)) { std::memory_order_acquire)) {
call_destination_->StartCall(std::move(call.handler));
return; return;
} }
break; break;
@ -249,6 +251,7 @@ void ClientCall::StartCall(const grpc_op& send_initial_metadata_op) {
if (call_state_.compare_exchange_strong(cur_state, kStarted, if (call_state_.compare_exchange_strong(cur_state, kStarted,
std::memory_order_acq_rel, std::memory_order_acq_rel,
std::memory_order_acquire)) { std::memory_order_acquire)) {
call_destination_->StartCall(std::move(call.handler));
auto unordered_start = reinterpret_cast<UnorderedStart*>(cur_state); auto unordered_start = reinterpret_cast<UnorderedStart*>(cur_state);
while (unordered_start->next != nullptr) { while (unordered_start->next != nullptr) {
unordered_start->start_pending_batch(); unordered_start->start_pending_batch();

Loading…
Cancel
Save