mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-24 16:42:05 +00:00
Minor enhancement. [#CLICKHOUSE-2910]
This commit is contained in:
parent
392f6e0c6c
commit
e031b5360a
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user