Dan Burkert has posted comments on this change.

Change subject: [c++ client] re-acquire authn token if expired
......................................................................


Patch Set 16:

(4 comments)

http://gerrit.cloudera.org:8080/#/c/6648/16/src/kudu/client/client-internal.cc
File src/kudu/client/client-internal.cc:

PS16, Line 731: ANY_BUT_AUTHN_OTKEN
PRIMARY


Line 740:   DCHECK(creds_policy == CredentialsPolicy::ANY_CREDENTIALS ||
Isn't this statically verified by the compiler?


Line 753:   if (leader_master_rpc_primary_creds_ || need_new_rpc_primary_creds) 
{
I was having a hard time following this, so I tried to take a crack at reducing 
the number of branches, this is what I came up with (in particular the two 
boolean flags are removed, since I had trouble following those):

if (leader_master_rpc_primary_creds_) {
  // Piggy back on an existing connection with primary credentials.
  leader_master_callbacks_primary_creds_.push_back(cb);
} else if (leader_master_rpc_any_creds_ &&
           cred_policy == CredentialsPolicy::ANY_CREDENTIALS) {
  // Piggy back on an existing connection with any credentials.
  leader_master_callbacks_any_creds_.push_back(cb);
} else {
  // There are no existing connections, create a new one with the required 
policy.

  scoped_refptr<internal::ConnectToClusterRpc> rpc(
      new internal::ConnectToClusterRpc(
        std::bind(&KuduClient::Data::ConnectedToClusterCb, this,
          std::placeholders::_1,
          std::placeholders::_2,
          std::placeholders::_3,
          creds_policy),
        std::move(master_sockaddrs),
        deadline,
        client->default_rpc_timeout(),
        messenger_,
        creds_policy));

  switch (creds_policy) {
    case PRIMARY_CREDENTIALS:
      leader_master_rpc_primary_creds_.reset(rpc.get());
      leader_master_callbacks_primary_creds_.push_back(cb);
      break;
    case ANY_CREDENTIALS:
      leader_master_rpc_any_creds_.reset(rpc.get());
      leader_master_callbacks_any_creds_.push_back(cb);
      break;
  }
  l.unlock();
  rpc->SendRpc();
}

hopefully that's simpler?


Line 761:     scoped_refptr<internal::ConnectToClusterRpc>& rpc(
This statement confusing.  I think it's copying the scoped_refptr to an unnamed 
stack allocated variable, and then taking a reference to that, but I'm not 
really sure.  I think what you want is 

scoped_refptr<internal::ConnectToClusterRpc>& rpc = need_new_rpc_primary_creds 
? leader_master_rpc_primary_creds_ : leader_master_rpc_any_creds_;

I really think we should forbid taking references to unbound variables, the 
lifetime semantics are just too confusing, and there's never a good reason to 
do it.


-- 
To view, visit http://gerrit.cloudera.org:8080/6648
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: I418497ac59cfd4e476e9bfc6abe6b10b487712f5
Gerrit-PatchSet: 16
Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-Owner: Alexey Serbin <aser...@cloudera.com>
Gerrit-Reviewer: Alexey Serbin <aser...@cloudera.com>
Gerrit-Reviewer: Dan Burkert <danburk...@apache.org>
Gerrit-Reviewer: Kudu Jenkins
Gerrit-Reviewer: Tidy Bot
Gerrit-Reviewer: Todd Lipcon <t...@apache.org>
Gerrit-HasComments: Yes

Reply via email to