diff --git a/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/lib/fs/filesystem.cc b/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/lib/fs/filesystem.cc index d22dd51cda..1808b85fc1 100644 --- a/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/lib/fs/filesystem.cc +++ b/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/lib/fs/filesystem.cc @@ -171,7 +171,6 @@ FileSystemImpl::~FileSystemImpl() { **/ io_service_->Stop(); worker_threads_.clear(); - io_service_.reset(nullptr); } void FileSystemImpl::Connect(const std::string &server, diff --git a/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/lib/fs/filesystem.h b/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/lib/fs/filesystem.h index cc8a8e1cef..772f93b8f6 100644 --- a/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/lib/fs/filesystem.h +++ b/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/lib/fs/filesystem.h @@ -105,6 +105,11 @@ public: private: + /** + * The IoService must be the first member variable to ensure that it gets + * destroyed last. This allows other members to dequeue things from the + * service in their own destructors. + **/ std::unique_ptr io_service_; NameNodeOperations nn_; const std::string client_name_; @@ -120,8 +125,6 @@ private: std::vector worker_threads_; }; - - } #endif