HDFS-11436: libhdfs++: Fix race condition in ScopedResolver. 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/606d20c6 Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/606d20c6 Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/606d20c6 Branch: refs/heads/HDFS-7240 Commit: 606d20c6c0678be0cc7d0163defceacd1ffe03ae Parents: 8783461 Author: James <j...@apache.org> Authored: Wed Feb 22 12:12:24 2017 -0500 Committer: James Clampffer <james.clampf...@hp.com> Committed: Thu Mar 22 17:19:47 2018 -0400 ---------------------------------------------------------------------- .../src/main/native/libhdfspp/lib/common/namenode_info.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hadoop/blob/606d20c6/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/lib/common/namenode_info.cc ---------------------------------------------------------------------- diff --git a/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/lib/common/namenode_info.cc b/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/lib/common/namenode_info.cc index bd43091..bd3f44f 100644 --- a/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/lib/common/namenode_info.cc +++ b/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/lib/common/namenode_info.cc @@ -109,13 +109,14 @@ class ScopedResolver { // Now set up the promise, set it in async_resolve's callback result_status_ = std::make_shared<std::promise<Status>>(); + std::shared_ptr<std::promise<Status>> shared_result = result_status_; // Callback to pull a copy of endpoints out of resolver and set promise - auto callback = [this](const asio::error_code &ec, ::asio::ip::tcp::resolver::iterator out) { + auto callback = [this, shared_result](const asio::error_code &ec, ::asio::ip::tcp::resolver::iterator out) { if(!ec) { std::copy(out, ::asio::ip::tcp::resolver::iterator(), std::back_inserter(endpoints_)); } - result_status_->set_value( ToStatus(ec) ); + shared_result->set_value( ToStatus(ec) ); }; resolver_.async_resolve(query_, callback); return true; --------------------------------------------------------------------- To unsubscribe, e-mail: common-commits-unsubscr...@hadoop.apache.org For additional commands, e-mail: common-commits-h...@hadoop.apache.org