diff options
author | Andrew Morrow <acm@10gen.com> | 2013-03-29 14:14:36 -0400 |
---|---|---|
committer | Andrew Morrow <acm@10gen.com> | 2013-03-29 14:49:17 -0400 |
commit | 85fc27444fa888d30cba56b31b6dfec8072a9116 (patch) | |
tree | c7746ef82e40250a49316826f98e777b187555f2 | |
parent | 9ba71622c9cf2af20c72469601aaf0eebd5f6e4c (diff) | |
download | mongo-85fc27444fa888d30cba56b31b6dfec8072a9116.tar.gz |
SERVER-9047 Don't limit line length when reading numa_maps
-rw-r--r-- | src/mongo/util/version.cpp | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/src/mongo/util/version.cpp b/src/mongo/util/version.cpp index 0d8ca561db6..5337a33de85 100644 --- a/src/mongo/util/version.cpp +++ b/src/mongo/util/version.cpp @@ -227,27 +227,24 @@ namespace mongo { std::ifstream f("/proc/self/numa_maps", std::ifstream::in); if (f.is_open()) { - char line[100]; //we only need the first line - f.getline(line, sizeof(line)); + std::string line; //we only need the first line + std::getline(f, line); if (f.fail()) { warning() << "failed to read from /proc/self/numa_maps: " << errnoWithDescription() << startupWarningsLog; warned = true; } else { - // just in case... - line[98] = ' '; - line[99] = '\0'; - // skip over pointer - const char* space = strchr(line, ' '); - - if ( ! space ) { + std::string::size_type where = line.find(' '); + if ( (where == std::string::npos) || (++where == line.size()) ) { log() << startupWarningsLog; - log() << "** WARNING: cannot parse numa_maps" << startupWarningsLog; + log() << "** WARNING: cannot parse numa_maps line: '" << line << "'" << startupWarningsLog; warned = true; } - else if ( ! startsWith(space+1, "interleave") ) { + // if the text following the space doesn't begin with 'interleave', then + // issue the warning. + else if ( line.find("interleave", where) != where ) { log() << startupWarningsLog; log() << "** WARNING: You are running on a NUMA machine." << startupWarningsLog; log() << "** We suggest launching mongod like this to avoid performance problems:" << startupWarningsLog; |