Minor enhancement. [#CLICKHOUSE-2910]

This commit is contained in:
Vitaliy Lyudvichenko 2018-06-18 16:50:20 +03:00
parent 392f6e0c6c
commit e031b5360a

View File

@ -244,25 +244,18 @@ int TaskStatsInfoGetter::getDefaultTid()
return default_tid;
}
bool TaskStatsInfoGetter::checkProcessHasRequiredPermissions()
{
/// 0 - wasn't checked
/// 1 - checked, has no permissions
/// 2 - checked, has permissions
static std::atomic<int> premissions_check_status{0};
int status = premissions_check_status.load(std::memory_order_relaxed);
if (status == 0)
static bool tryGetTaskStats()
{
TaskStatsInfoGetter getter;
::taskstats stat;
status = getter.tryGetStat(stat) ? 2 : 1;
premissions_check_status.store(status, std::memory_order_relaxed);
return getter.tryGetStat(stat);
}
return status == 2;
bool TaskStatsInfoGetter::checkProcessHasRequiredPermissions()
{
/// It is thread- and exception- safe since C++11
static bool res = tryGetTaskStats();
return res;
}
}