diff options
author | Mathias Stearn <mathias@10gen.com> | 2013-05-14 13:28:59 -0400 |
---|---|---|
committer | Mathias Stearn <mathias@10gen.com> | 2013-05-14 13:46:36 -0400 |
commit | 3210cf876673fa9ed3a9e56b1f94cc192fa245b5 (patch) | |
tree | 8448de3f47c5babe290122c5a1de52b5133d84e9 | |
parent | 763c40a81f19c6cd29dfe9c45251abf69e361223 (diff) | |
download | mongo-3210cf876673fa9ed3a9e56b1f94cc192fa245b5.tar.gz |
SERVER-9411 Fix IO error messages from sorter on windows.
-rw-r--r-- | src/mongo/db/sorter/sorter.cpp | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/src/mongo/db/sorter/sorter.cpp b/src/mongo/db/sorter/sorter.cpp index 0f6dee20759..e7b6f945fb0 100644 --- a/src/mongo/db/sorter/sorter.cpp +++ b/src/mongo/db/sorter/sorter.cpp @@ -49,6 +49,14 @@ namespace mongo { namespace sorter { using namespace mongoutils; + // We need to use the "real" errno everywhere, not GetLastError() on Windows + inline std::string myErrnoWithDescription() { + int errnoCopy = errno; + StringBuilder sb; + sb << "errno:" << errnoCopy << ' ' << strerror(errnoCopy); + return sb.str(); + } + template<typename Data, typename Comparator> void compIsntSane(const Comparator& comp, const Data& lhs, const Data& rhs) { PRINT(typeid(comp).name()); @@ -139,7 +147,7 @@ namespace mongo { , _file(_fileName.c_str(), std::ios::in | std::ios::binary) { massert(16814, str::stream() << "error opening file \"" << _fileName << "\": " - << errnoWithDescription(), + << myErrnoWithDescription(), _file.good()); massert(16815, str::stream() << "unexpected empty file: " << _fileName, @@ -193,7 +201,7 @@ namespace mongo { msgasserted(16817, str::stream() << "error reading file \"" << _fileName << "\": " - << errnoWithDescription()); + << myErrnoWithDescription()); } verify(_file.gcount() == static_cast<std::streamsize>(size)); } @@ -627,7 +635,7 @@ namespace mongo { _file.open(_fileName.c_str(), ios::binary | ios::out); massert(16818, str::stream() << "error opening file \"" << _fileName << "\": " - << errnoWithDescription(), + << sorter::myErrnoWithDescription(), _file.good()); _fileDeleter = boost::make_shared<sorter::FileDeleter>(_fileName); @@ -656,7 +664,7 @@ namespace mongo { _file.write(_buffer.buf(), size); } catch (const std::exception&) { msgasserted(16821, str::stream() << "error writing to file \"" << _fileName << "\": " - << errnoWithDescription()); + << sorter::myErrnoWithDescription()); } _buffer.reset(); |