Minor cleanups.

reviewable/pr14886/r6
Mark D. Roth 7 years ago
parent b1c1309bfc
commit 3e74a18668
  1. 3
      src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc
  2. 20
      src/core/ext/filters/client_channel/lb_policy/subchannel_list.h

@ -294,7 +294,7 @@ void PickFirst::UpdateLocked(const grpc_channel_args& args) {
return; return;
} }
const grpc_lb_addresses* addresses = const grpc_lb_addresses* addresses =
(const grpc_lb_addresses*)arg->value.pointer.p; static_cast<const grpc_lb_addresses*>(arg->value.pointer.p);
if (grpc_lb_pick_first_trace.enabled()) { if (grpc_lb_pick_first_trace.enabled()) {
gpr_log(GPR_INFO, gpr_log(GPR_INFO,
"Pick First %p received update with %" PRIuPTR " addresses", this, "Pick First %p received update with %" PRIuPTR " addresses", this,
@ -344,7 +344,6 @@ void PickFirst::UpdateLocked(const grpc_channel_args& args) {
subchannel_list->num_subchannels()); subchannel_list->num_subchannels());
} }
if (selected_->connected_subchannel() != nullptr) { if (selected_->connected_subchannel() != nullptr) {
// FIXME: restructure to work more like RR?
sd->SetConnectedSubchannelFromLocked(selected_); sd->SetConnectedSubchannelFromLocked(selected_);
} }
selected_ = sd; selected_ = sd;

@ -94,13 +94,14 @@ class SubchannelData {
return curr_connectivity_state_; return curr_connectivity_state_;
} }
// FIXME: remove // Used to set the connected subchannel in cases where we are retaining a
// An alternative to SetConnectedSubchannelFromSubchannelLocked() for // subchannel from a previous subchannel list. This is slightly more
// cases where we are retaining a connected subchannel from a previous // efficient than getting the connected subchannel from the subchannel,
// subchannel list. This is slightly more efficient than getting the // because that approach requires the use of a mutex, whereas this one
// connected subchannel from the subchannel, because that approach // only mutates a refcount.
// requires the use of a mutex, whereas this one only mutates a // TODO(roth): This method is a bit of a hack and is used only in
// refcount. // pick_first. When we have time, find a way to remove this, possibly
// by making pick_first work more like round_robin.
void SetConnectedSubchannelFromLocked(SubchannelData* other) { void SetConnectedSubchannelFromLocked(SubchannelData* other) {
GPR_ASSERT(subchannel_ == other->subchannel_); GPR_ASSERT(subchannel_ == other->subchannel_);
connected_subchannel_ = other->connected_subchannel_; // Adds ref. connected_subchannel_ = other->connected_subchannel_; // Adds ref.
@ -164,11 +165,12 @@ class SubchannelData {
// Implementations can use connectivity_state() to get the new // Implementations can use connectivity_state() to get the new
// connectivity state. // connectivity state.
// Implementations must invoke either StopConnectivityWatch() or again // Implementations must invoke either StopConnectivityWatch() or again
// call StartConnectivityWatch() before returning. // call StartOrRenewConnectivityWatch() before returning.
virtual void ProcessConnectivityChangeLocked(grpc_error* error) GRPC_ABSTRACT; virtual void ProcessConnectivityChangeLocked(grpc_error* error) GRPC_ABSTRACT;
private: private:
// FIXME: document // Updates connected_subchannel_ based on pending_connectivity_state_unsafe_.
// Returns true if the connectivity state should be reported.
bool UpdateConnectedSubchannelLocked(); bool UpdateConnectedSubchannelLocked();
static void OnConnectivityChangedLocked(void* arg, grpc_error* error); static void OnConnectivityChangedLocked(void* arg, grpc_error* error);

Loading…
Cancel
Save