Skip to content

Commit

Permalink
PARQUET-846: CpuInfo::Init() is not thread safe
Browse files Browse the repository at this point in the history
Author: Deepak Majeti <deepak.majeti@hpe.com>

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

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

Change-Id: I33bef39d6291dfe207bfc248cf7ce571f6308ad3
  • Loading branch information
Deepak Majeti authored and wesm committed Jan 26, 2017
1 parent c016b72 commit 61b7b12
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions cpp/src/parquet/util/cpu-info.cc
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
#include <cstdint>
#include <fstream>
#include <iostream>
#include <mutex>
#include <sstream>
#include <string>

Expand All @@ -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;
Expand All @@ -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;
Expand Down

0 comments on commit 61b7b12

Please sign in to comment.