Add more lock annotations in client channel code. (#25797)

reviewable/pr25653/r2
Mark D. Roth 4 years ago committed by GitHub
parent 077f627aef
commit c69523d823
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      src/core/ext/filters/client_channel/client_channel_channelz.h
  2. 29
      src/core/ext/filters/client_channel/health/health_check_client.h
  3. 21
      src/core/ext/filters/client_channel/http_connect_handshaker.cc
  4. 3
      src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.h
  5. 2
      src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_impl.cc
  6. 9
      src/core/ext/filters/client_channel/resolver/fake/fake_resolver.h

@ -63,7 +63,7 @@ class SubchannelNode : public BaseNode {
private:
Atomic<grpc_connectivity_state> connectivity_state_{GRPC_CHANNEL_IDLE};
Mutex socket_mu_;
RefCountedPtr<SocketNode> child_socket_;
RefCountedPtr<SocketNode> child_socket_ ABSL_GUARDED_BY(socket_mu_);
std::string target_;
CallCountingHelper call_counter_;
ChannelTrace trace_;

@ -64,7 +64,7 @@ class HealthCheckClient : public InternallyRefCounted<HealthCheckClient> {
void Orphan() override;
void StartCall();
void StartCall() ABSL_EXCLUSIVE_LOCKS_REQUIRED(&HealthCheckClient::mu_);
private:
void Cancel();
@ -72,8 +72,8 @@ class HealthCheckClient : public InternallyRefCounted<HealthCheckClient> {
void StartBatch(grpc_transport_stream_op_batch* batch);
static void StartBatchInCallCombiner(void* arg, grpc_error* error);
// Requires holding health_check_client_->mu_.
void CallEndedLocked(bool retry);
void CallEndedLocked(bool retry)
ABSL_EXCLUSIVE_LOCKS_REQUIRED(health_check_client_->mu_);
static void OnComplete(void* arg, grpc_error* error);
static void RecvInitialMetadataReady(void* arg, grpc_error* error);
@ -141,14 +141,14 @@ class HealthCheckClient : public InternallyRefCounted<HealthCheckClient> {
};
void StartCall();
void StartCallLocked(); // Requires holding mu_.
void StartCallLocked() ABSL_EXCLUSIVE_LOCKS_REQUIRED(mu_);
void StartRetryTimerLocked(); // Requires holding mu_.
void StartRetryTimerLocked() ABSL_EXCLUSIVE_LOCKS_REQUIRED(mu_);
static void OnRetryTimer(void* arg, grpc_error* error);
void SetHealthStatus(grpc_connectivity_state state, const char* reason);
void SetHealthStatusLocked(grpc_connectivity_state state,
const char* reason); // Requires holding mu_.
void SetHealthStatusLocked(grpc_connectivity_state state, const char* reason)
ABSL_EXCLUSIVE_LOCKS_REQUIRED(mu_);
std::string service_name_;
RefCountedPtr<ConnectedSubchannel> connected_subchannel_;
@ -156,18 +156,19 @@ class HealthCheckClient : public InternallyRefCounted<HealthCheckClient> {
RefCountedPtr<channelz::SubchannelNode> channelz_node_;
Mutex mu_;
RefCountedPtr<ConnectivityStateWatcherInterface> watcher_;
bool shutting_down_ = false;
RefCountedPtr<ConnectivityStateWatcherInterface> watcher_
ABSL_GUARDED_BY(mu_);
bool shutting_down_ ABSL_GUARDED_BY(mu_) = false;
// The data associated with the current health check call. It holds a ref
// to this HealthCheckClient object.
OrphanablePtr<CallState> call_state_;
OrphanablePtr<CallState> call_state_ ABSL_GUARDED_BY(mu_);
// Call retry state.
BackOff retry_backoff_;
grpc_timer retry_timer_;
grpc_closure retry_timer_callback_;
bool retry_timer_callback_pending_ = false;
BackOff retry_backoff_ ABSL_GUARDED_BY(mu_);
grpc_timer retry_timer_ ABSL_GUARDED_BY(mu_);
grpc_closure retry_timer_callback_ ABSL_GUARDED_BY(mu_);
bool retry_timer_callback_pending_ ABSL_GUARDED_BY(mu_) = false;
};
} // namespace grpc_core

@ -55,8 +55,9 @@ class HttpConnectHandshaker : public Handshaker {
private:
~HttpConnectHandshaker() override;
void CleanupArgsForFailureLocked();
void HandshakeFailedLocked(grpc_error* error);
void CleanupArgsForFailureLocked() ABSL_EXCLUSIVE_LOCKS_REQUIRED(mu_);
void HandshakeFailedLocked(grpc_error* error)
ABSL_EXCLUSIVE_LOCKS_REQUIRED(mu_);
static void OnWriteDone(void* arg, grpc_error* error);
static void OnReadDone(void* arg, grpc_error* error);
static void OnWriteDoneScheduler(void* arg, grpc_error* error);
@ -64,21 +65,21 @@ class HttpConnectHandshaker : public Handshaker {
Mutex mu_;
bool is_shutdown_ = false;
bool is_shutdown_ ABSL_GUARDED_BY(mu_) = false;
// Endpoint and read buffer to destroy after a shutdown.
grpc_endpoint* endpoint_to_destroy_ = nullptr;
grpc_slice_buffer* read_buffer_to_destroy_ = nullptr;
grpc_endpoint* endpoint_to_destroy_ ABSL_GUARDED_BY(mu_) = nullptr;
grpc_slice_buffer* read_buffer_to_destroy_ ABSL_GUARDED_BY(mu_) = nullptr;
// State saved while performing the handshake.
HandshakerArgs* args_ = nullptr;
grpc_closure* on_handshake_done_ = nullptr;
// Objects for processing the HTTP CONNECT request and response.
grpc_slice_buffer write_buffer_;
grpc_closure request_done_closure_;
grpc_closure response_read_closure_;
grpc_http_parser http_parser_;
grpc_http_response http_response_;
grpc_slice_buffer write_buffer_ ABSL_GUARDED_BY(mu_);
grpc_closure request_done_closure_ ABSL_GUARDED_BY(mu_);
grpc_closure response_read_closure_ ABSL_GUARDED_BY(mu_);
grpc_http_parser http_parser_ ABSL_GUARDED_BY(mu_);
grpc_http_response http_response_ ABSL_GUARDED_BY(mu_);
};
HttpConnectHandshaker::~HttpConnectHandshaker() {

@ -66,7 +66,8 @@ class GrpcLbClientStats : public RefCounted<GrpcLbClientStats> {
gpr_atm num_calls_finished_with_client_failed_to_send_ = 0;
gpr_atm num_calls_finished_known_received_ = 0;
Mutex drop_count_mu_; // Guards drop_token_counts_.
std::unique_ptr<DroppedCallCounts> drop_token_counts_;
std::unique_ptr<DroppedCallCounts> drop_token_counts_
ABSL_GUARDED_BY(drop_count_mu_);
};
} // namespace grpc_core

@ -69,7 +69,7 @@ class CircuitBreakerCallCounterMap {
private:
Mutex mu_;
std::map<Key, CallCounter*> map_;
std::map<Key, CallCounter*> map_ ABSL_GUARDED_BY(mu_);
};
CircuitBreakerCallCounterMap* g_call_counter_map = nullptr;

@ -82,12 +82,11 @@ class FakeResolverResponseGenerator
// Mutex protecting the members below.
Mutex mu_;
RefCountedPtr<FakeResolver> resolver_;
Resolver::Result result_;
bool has_result_ = false;
RefCountedPtr<FakeResolver> resolver_ ABSL_GUARDED_BY(mu_);
Resolver::Result result_ ABSL_GUARDED_BY(mu_);
bool has_result_ ABSL_GUARDED_BY(mu_) = false;
};
} // namespace grpc_core
#endif /* GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_RESOLVER_FAKE_FAKE_RESOLVER_H \
*/
#endif // GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_RESOLVER_FAKE_FAKE_RESOLVER_H

Loading…
Cancel
Save