fix: typo when get cpu cores
This commit is contained in:
parent
f4dd1895b2
commit
d5b0d39c40
|
@ -121,7 +121,7 @@ LONG WINAPI exceptionHandler(LPEXCEPTION_POINTERS exception);
|
||||||
static pid_t tsProcId;
|
static pid_t tsProcId;
|
||||||
static char tsSysNetFile[] = "/proc/net/dev";
|
static char tsSysNetFile[] = "/proc/net/dev";
|
||||||
static char tsSysCpuFile[] = "/proc/stat";
|
static char tsSysCpuFile[] = "/proc/stat";
|
||||||
static char tsCpuPeroidFile[] = "/sys/fs/cgroup/cpu/cpu.cfs_period_us";
|
static char tsCpuPeriodFile[] = "/sys/fs/cgroup/cpu/cpu.cfs_period_us";
|
||||||
static char tsCpuQuotaFile[] = "/sys/fs/cgroup/cpu/cpu.cfs_quota_us";
|
static char tsCpuQuotaFile[] = "/sys/fs/cgroup/cpu/cpu.cfs_quota_us";
|
||||||
static char tsProcCpuFile[25] = {0};
|
static char tsProcCpuFile[25] = {0};
|
||||||
static char tsProcMemFile[25] = {0};
|
static char tsProcMemFile[25] = {0};
|
||||||
|
@ -504,31 +504,31 @@ static int32_t taosCntrGetCpuCores(float *numOfCores) {
|
||||||
#else
|
#else
|
||||||
TdFilePtr pFile = NULL;
|
TdFilePtr pFile = NULL;
|
||||||
if (!(pFile = taosOpenFile(tsCpuQuotaFile, TD_FILE_READ | TD_FILE_STREAM))) {
|
if (!(pFile = taosOpenFile(tsCpuQuotaFile, TD_FILE_READ | TD_FILE_STREAM))) {
|
||||||
goto _physical;
|
goto _sys;
|
||||||
}
|
}
|
||||||
char qline[32] = {0};
|
char qline[32] = {0};
|
||||||
if (taosGetsFile(pFile, sizeof(qline), qline) < 0) {
|
if (taosGetsFile(pFile, sizeof(qline), qline) < 0) {
|
||||||
taosCloseFile(&pFile);
|
taosCloseFile(&pFile);
|
||||||
goto _physical;
|
goto _sys;
|
||||||
}
|
}
|
||||||
taosCloseFile(&pFile);
|
taosCloseFile(&pFile);
|
||||||
float quota = taosStr2Float(qline, NULL);
|
float quota = taosStr2Float(qline, NULL);
|
||||||
if (quota < 0) {
|
if (quota < 0) {
|
||||||
goto _physical;
|
goto _sys;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(pFile = taosOpenFile(tsCpuPeroidFile, TD_FILE_READ | TD_FILE_STREAM))) {
|
if (!(pFile = taosOpenFile(tsCpuPeriodFile, TD_FILE_READ | TD_FILE_STREAM))) {
|
||||||
goto _physical;
|
goto _sys;
|
||||||
}
|
}
|
||||||
char pline[32] = {0};
|
char pline[32] = {0};
|
||||||
if (taosGetsFile(pFile, sizeof(pline), pline) < 0) {
|
if (taosGetsFile(pFile, sizeof(pline), pline) < 0) {
|
||||||
taosCloseFile(&pFile);
|
taosCloseFile(&pFile);
|
||||||
goto _physical;
|
goto _sys;
|
||||||
}
|
}
|
||||||
taosCloseFile(&pFile);
|
taosCloseFile(&pFile);
|
||||||
|
|
||||||
float peroid = taosStr2Float(pline, NULL);
|
float period = taosStr2Float(pline, NULL);
|
||||||
float quotaCores = quota / peroid;
|
float quotaCores = quota / period;
|
||||||
float sysCores = sysconf(_SC_NPROCESSORS_ONLN);
|
float sysCores = sysconf(_SC_NPROCESSORS_ONLN);
|
||||||
if (quotaCores < sysCores && quotaCores > 0) {
|
if (quotaCores < sysCores && quotaCores > 0) {
|
||||||
*numOfCores = quotaCores;
|
*numOfCores = quotaCores;
|
||||||
|
@ -536,7 +536,7 @@ static int32_t taosCntrGetCpuCores(float *numOfCores) {
|
||||||
*numOfCores = sysCores;
|
*numOfCores = sysCores;
|
||||||
}
|
}
|
||||||
goto _end;
|
goto _end;
|
||||||
_physical:
|
_sys:
|
||||||
*numOfCores = sysconf(_SC_NPROCESSORS_ONLN);
|
*numOfCores = sysconf(_SC_NPROCESSORS_ONLN);
|
||||||
_end:
|
_end:
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Loading…
Reference in New Issue