summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Reams <jbreams@mongodb.com>2017-03-27 16:20:40 -0400
committerJonathan Reams <jbreams@mongodb.com>2017-04-07 11:25:19 -0400
commit0072cd5d0c15e8721c3055928ee5b08709097350 (patch)
treeb22e8a6e2592d36e8756eda6c62a07f67ac57f1f
parentc53363894310c144aefd06ce323d348735789601 (diff)
downloadmongo-0072cd5d0c15e8721c3055928ee5b08709097350.tar.gz
SERVER-27687 Fix cpuAddrSize detection on Linux for hostInfo command
(cherry picked from commit d2211f33b794dc638bec61a14ae9ba68e76b8946)
-rw-r--r--jstests/core/hostinfo.js10
-rw-r--r--src/mongo/util/processinfo_linux.cpp2
2 files changed, 11 insertions, 1 deletions
diff --git a/jstests/core/hostinfo.js b/jstests/core/hostinfo.js
index 6d27b195f39..dbf1c95af72 100644
--- a/jstests/core/hostinfo.js
+++ b/jstests/core/hostinfo.js
@@ -31,3 +31,13 @@ if (hostinfo.os.type != "") {
assert.neq(hostinfo.system.cpuArch, "" || null, "Missing CPU Architecture");
assert.neq(hostinfo.system.numaEnabled, "" || null, "Missing NUMA flag");
}
+
+var buildInfo = assert.commandWorked(db.runCommand({buildInfo: 1}));
+if (buildInfo.buildEnvironment && buildInfo.buildEnvironment.target_arch) {
+ let targetArch = buildInfo.buildEnvironment.target_arch;
+ if (targetArch == "i386")
+ assert.eq(hostinfo.system.cpuAddrSize, 32);
+ else
+ assert.eq(hostinfo.system.cpuAddrSize, 64);
+ assert.eq(hostinfo.system.cpuAddrSize, buildInfo.bits);
+}
diff --git a/src/mongo/util/processinfo_linux.cpp b/src/mongo/util/processinfo_linux.cpp
index ffe17d9805c..910015215e0 100644
--- a/src/mongo/util/processinfo_linux.cpp
+++ b/src/mongo/util/processinfo_linux.cpp
@@ -479,7 +479,7 @@ void ProcessInfo::SystemInfo::collectSystemInfo() {
osName = distroName;
osVersion = distroVersion;
memSize = LinuxSysHelper::getSystemMemorySize();
- addrSize = (string(unameData.machine).find("x86_64") != string::npos ? 64 : 32);
+ addrSize = sizeof(void*) * CHAR_BIT;
numCores = cpuCount;
pageSize = static_cast<unsigned long long>(sysconf(_SC_PAGESIZE));
cpuArch = unameData.machine;