forked from lix-project/lix
parent
1e6a5d1ff6
commit
fa99ef6a87
|
@ -730,23 +730,19 @@ unsigned int getMaxCPU()
|
||||||
auto cgroupFS = getCgroupFS();
|
auto cgroupFS = getCgroupFS();
|
||||||
if (!cgroupFS) return 0;
|
if (!cgroupFS) return 0;
|
||||||
|
|
||||||
if (!pathExists("/proc/self/cgroup")) return 0;
|
auto cgroups = getCgroups("/proc/self/cgroupp");
|
||||||
|
|
||||||
auto cgroups = getCgroups("/proc/self/cgroup");
|
|
||||||
auto cgroup = cgroups[""];
|
auto cgroup = cgroups[""];
|
||||||
if (cgroup == "") return 0;
|
if (cgroup == "") return 0;
|
||||||
|
|
||||||
auto cpuFile = *cgroupFS + "/" + cgroup + "/cpu.max";
|
auto cpuFile = *cgroupFS + "/" + cgroup + "/cpu.max";
|
||||||
|
|
||||||
if (pathExists(cpuFile)) {
|
|
||||||
auto cpuMax = readFile(cpuFile);
|
auto cpuMax = readFile(cpuFile);
|
||||||
auto cpuMaxParts = tokenizeString<std::vector<std::string>>(cpuMax, " \n");
|
auto cpuMaxParts = tokenizeString<std::vector<std::string>>(cpuMax, " \n");
|
||||||
auto quota = cpuMaxParts[0];
|
auto quota = cpuMaxParts[0];
|
||||||
auto period = cpuMaxParts[1];
|
auto period = cpuMaxParts[1];
|
||||||
if (quota != "max")
|
if (quota != "max")
|
||||||
return std::ceil(std::stoi(quota) / std::stof(period));
|
return std::ceil(std::stoi(quota) / std::stof(period));
|
||||||
}
|
} catch (Error &) { ignoreException(lvlDebug); }
|
||||||
} catch (Error &) { ignoreException(); }
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1408,7 +1404,7 @@ std::string shellEscape(const std::string_view s)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ignoreException()
|
void ignoreException(Verbosity lvl)
|
||||||
{
|
{
|
||||||
/* Make sure no exceptions leave this function.
|
/* Make sure no exceptions leave this function.
|
||||||
printError() also throws when remote is closed. */
|
printError() also throws when remote is closed. */
|
||||||
|
@ -1416,7 +1412,7 @@ void ignoreException()
|
||||||
try {
|
try {
|
||||||
throw;
|
throw;
|
||||||
} catch (std::exception & e) {
|
} catch (std::exception & e) {
|
||||||
printError("error (ignored): %1%", e.what());
|
printMsg(lvl, "error (ignored): %1%", e.what());
|
||||||
}
|
}
|
||||||
} catch (...) { }
|
} catch (...) { }
|
||||||
}
|
}
|
||||||
|
|
|
@ -528,7 +528,7 @@ std::string shellEscape(const std::string_view s);
|
||||||
|
|
||||||
/* Exception handling in destructors: print an error message, then
|
/* Exception handling in destructors: print an error message, then
|
||||||
ignore the exception. */
|
ignore the exception. */
|
||||||
void ignoreException();
|
void ignoreException(Verbosity lvl = lvlError);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue