Browse Source

HDFS-9486. Fix valgrind failures when using more than 1 io_service worker thread. Contributed by James Clampffer.

James 9 years ago
parent
commit
33192bb266

+ 0 - 1
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,

+ 5 - 2
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<IoServiceImpl> io_service_;
   NameNodeOperations nn_;
   const std::string client_name_;
@@ -120,8 +125,6 @@ private:
   std::vector<WorkerPtr> worker_threads_;
 
 };
-
-
 }
 
 #endif