parquet-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From w...@apache.org
Subject parquet-cpp git commit: PARQUET-846: CpuInfo::Init() is not thread safe
Date Thu, 26 Jan 2017 23:39:13 GMT
Repository: parquet-cpp
Updated Branches:
  refs/heads/master 13da51d3f -> 921fd3028


PARQUET-846: CpuInfo::Init() is not thread safe

Author: Deepak Majeti <deepak.majeti@hpe.com>

Closes #230 from majetideepak/PARQUET-846 and squashes the following commits:

9007986 [Deepak Majeti] PARQUET-846: CpuInfo::Init() is not thread safe


Project: http://git-wip-us.apache.org/repos/asf/parquet-cpp/repo
Commit: http://git-wip-us.apache.org/repos/asf/parquet-cpp/commit/921fd302
Tree: http://git-wip-us.apache.org/repos/asf/parquet-cpp/tree/921fd302
Diff: http://git-wip-us.apache.org/repos/asf/parquet-cpp/diff/921fd302

Branch: refs/heads/master
Commit: 921fd3028e88040345dd982cdfb57a90f4c89094
Parents: 13da51d
Author: Deepak Majeti <deepak.majeti@hpe.com>
Authored: Thu Jan 26 18:39:07 2017 -0500
Committer: Wes McKinney <wes.mckinney@twosigma.com>
Committed: Thu Jan 26 18:39:07 2017 -0500

----------------------------------------------------------------------
 src/parquet/util/cpu-info.cc | 6 ++++++
 1 file changed, 6 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/parquet-cpp/blob/921fd302/src/parquet/util/cpu-info.cc
----------------------------------------------------------------------
diff --git a/src/parquet/util/cpu-info.cc b/src/parquet/util/cpu-info.cc
index e8f6fac..f56d423 100644
--- a/src/parquet/util/cpu-info.cc
+++ b/src/parquet/util/cpu-info.cc
@@ -34,6 +34,7 @@
 #include <cstdint>
 #include <fstream>
 #include <iostream>
+#include <mutex>
 #include <sstream>
 #include <string>
 
@@ -53,6 +54,7 @@ int64_t CpuInfo::cache_sizes_[L3_CACHE + 1];
 int64_t CpuInfo::cycles_per_ms_;
 int CpuInfo::num_cores_ = 1;
 string CpuInfo::model_name_ = "unknown";  // NOLINT
+static std::mutex cpuinfo_mutex;
 
 static struct {
   string name;
@@ -76,6 +78,10 @@ int64_t ParseCPUFlags(const string& values) {
 }
 
 void CpuInfo::Init() {
+  std::lock_guard<std::mutex> cpuinfo_lock(cpuinfo_mutex);
+
+  if (initialized()) { return; }
+
   string line;
   string name;
   string value;


Mime
View raw message