[tsan] Flake fix in chaotic good connector

pull/37657/head
Craig Tiller 3 months ago
parent 1ed28f882f
commit 2aba75edaf
  1. 14
      src/core/ext/transport/chaotic_good/client/chaotic_good_connector.cc
  2. 2
      src/core/ext/transport/chaotic_good/client/chaotic_good_connector.h

@ -134,9 +134,12 @@ auto ChaoticGoodConnector::WaitForDataEndpointSetup(
endpoint) mutable {
ExecCtx exec_ctx;
if (!endpoint.ok() || self->handshake_mgr_ == nullptr) {
MutexLock lock(&self->mu_);
if (self->notify_ != nullptr) {
ExecCtx::Run(DEBUG_LOCATION,
std::exchange(self->notify_, nullptr),
GRPC_ERROR_CREATE("connect endpoint failed"));
}
return;
}
auto* chaotic_good_ext =
@ -240,9 +243,9 @@ void ChaoticGoodConnector::Connect(const Args& args, Result* result,
GRPC_ERROR_CREATE("connector shutdown"));
return;
}
notify_ = notify;
}
args_ = args;
notify_ = notify;
resolved_addr_ = EventEngine::ResolvedAddress(
reinterpret_cast<const sockaddr*>(args_.address->addr),
args_.address->len);
@ -253,11 +256,14 @@ void ChaoticGoodConnector::Connect(const Args& args, Result* result,
endpoint) mutable {
ExecCtx exec_ctx;
if (!endpoint.ok() || self->handshake_mgr_ == nullptr) {
MutexLock lock(&self->mu_);
if (self->notify_ != nullptr) {
auto endpoint_status = endpoint.status();
auto error = GRPC_ERROR_CREATE_REFERENCING("connect endpoint failed",
&endpoint_status, 1);
auto error = GRPC_ERROR_CREATE_REFERENCING(
"connect endpoint failed", &endpoint_status, 1);
ExecCtx::Run(DEBUG_LOCATION, std::exchange(self->notify_, nullptr),
error);
}
return;
}
auto* chaotic_good_ext =
@ -320,8 +326,8 @@ void ChaoticGoodConnector::OnHandshakeDone(
[self = RefAsSubclass<ChaoticGoodConnector>()](absl::Status status) {
GRPC_TRACE_LOG(chaotic_good, INFO)
<< "ChaoticGoodConnector::OnHandshakeDone: " << status;
if (status.ok()) {
MutexLock lock(&self->mu_);
if (status.ok()) {
self->result_->transport = new ChaoticGoodClientTransport(
std::move(self->control_endpoint_),
std::move(self->data_endpoint_), self->args_.channel_args,

@ -83,7 +83,7 @@ class ChaoticGoodConnector : public SubchannelConnector {
Mutex mu_;
Args args_;
Result* result_ ABSL_GUARDED_BY(mu_);
grpc_closure* notify_ = nullptr;
grpc_closure* notify_ ABSL_GUARDED_BY(mu_) = nullptr;
bool is_shutdown_ ABSL_GUARDED_BY(mu_) = false;
absl::StatusOr<grpc_event_engine::experimental::EventEngine::ResolvedAddress>
resolved_addr_;

Loading…
Cancel
Save