Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/mongo/util/processinfo_linux.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -496,6 +496,8 @@ class LinuxSysHelper {
if (f != nullptr) {
if (fgets(fstr, 1023, f) != nullptr)
fstr[strlen(fstr) < 1 ? 0 : strlen(fstr) - 1] = '\0';
else
fstr[0] = '\0';
fclose(f);
}
return fstr;
Expand Down
5 changes: 4 additions & 1 deletion src/third_party/tcmalloc/dist/tcmalloc/cpu_cache.cc
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ std::string parseLineFromFile(const char* fname) {
if (f != nullptr) {
if (fgets(fstr, 1023, f) != nullptr)
fstr[strlen(fstr) < 1 ? 0 : strlen(fstr) - 1] = '\0';
else
fstr[0] = '\0';
fclose(f);
}

Expand All @@ -69,7 +71,8 @@ unsigned long long getMemorySizeLimitInBytes() {
unsigned long long groupMemBytes = 0;
std::string groupLimit = parseLineFromFile(file);

if (!groupLimit.empty() ) {
// The "max" value in cgroups v2 means no limit.
if (!groupLimit.empty() && groupLimit != "max") {
return std::min(systemMemBytes, (unsigned long long)atoll(groupLimit.c_str()));
}
}
Expand Down