HDFS-11767: libhdfs++: SASL events should be scoped closer to usage. Contributed by James Clampffer
Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/57cdad73 Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/57cdad73 Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/57cdad73 Branch: refs/heads/HDFS-7240 Commit: 57cdad73deecdb39fbe3c43688dbd71bcfd0e31a Parents: b584e34 Author: James <j...@apache.org> Authored: Thu May 11 12:34:35 2017 -0400 Committer: James Clampffer <james.clampf...@hp.com> Committed: Thu Mar 22 17:19:47 2018 -0400 ---------------------------------------------------------------------- .../src/main/native/libhdfspp/lib/rpc/sasl_protocol.cc | 7 ++++--- .../src/main/native/libhdfspp/lib/rpc/sasl_protocol.h | 1 - 2 files changed, 4 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hadoop/blob/57cdad73/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/lib/rpc/sasl_protocol.cc ---------------------------------------------------------------------- diff --git a/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/lib/rpc/sasl_protocol.cc b/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/lib/rpc/sasl_protocol.cc index 83d4f88..49abe58 100644 --- a/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/lib/rpc/sasl_protocol.cc +++ b/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/lib/rpc/sasl_protocol.cc @@ -65,14 +65,12 @@ SaslProtocol::SaslProtocol(const std::string & cluster_name, SaslProtocol::~SaslProtocol() { - std::lock_guard<std::mutex> state_lock(sasl_state_lock_); - event_handlers_->call("SASL End", cluster_name_.c_str(), 0); + assert(state_ != kNegotiate); } void SaslProtocol::SetEventHandlers(std::shared_ptr<LibhdfsEvents> event_handlers) { std::lock_guard<std::mutex> state_lock(sasl_state_lock_); event_handlers_ = event_handlers; - event_handlers_->call("SASL Start", cluster_name_.c_str(), 0); } // SetEventHandlers() method void SaslProtocol::Authenticate(std::function<void(const Status & status, const AuthInfo new_auth_info)> callback) @@ -81,6 +79,7 @@ void SaslProtocol::Authenticate(std::function<void(const Status & status, const callback_ = callback; state_ = kNegotiate; + event_handlers_->call("SASL Start", cluster_name_.c_str(), 0); std::shared_ptr<RpcSaslProto> req_msg = std::make_shared<RpcSaslProto>(); req_msg->set_state(RpcSaslProto_SaslState_NEGOTIATE); @@ -353,6 +352,8 @@ bool SaslProtocol::SendSaslMessage(RpcSaslProto & message) bool SaslProtocol::AuthComplete(const Status & status, const AuthInfo & auth_info) { assert(lock_held(sasl_state_lock_)); // Must be holding lock before calling + state_ = kComplete; + event_handlers_->call("SASL End", cluster_name_.c_str(), 0); // RpcConnection might have been freed when we weren't looking. Lock it // to make sure it's there long enough for us http://git-wip-us.apache.org/repos/asf/hadoop/blob/57cdad73/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/lib/rpc/sasl_protocol.h ---------------------------------------------------------------------- diff --git a/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/lib/rpc/sasl_protocol.h b/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/lib/rpc/sasl_protocol.h index 3816cf9..a46ae08 100644 --- a/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/lib/rpc/sasl_protocol.h +++ b/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/lib/rpc/sasl_protocol.h @@ -56,7 +56,6 @@ private: enum State { kUnstarted, kNegotiate, - kAuthenticate, kComplete }; --------------------------------------------------------------------- To unsubscribe, e-mail: common-commits-unsubscr...@hadoop.apache.org For additional commands, e-mail: common-commits-h...@hadoop.apache.org