summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSpencer Jackson <spencer.jackson@mongodb.com>2015-10-28 10:38:02 -0400
committerSpencer Jackson <spencer.jackson@mongodb.com>2015-11-05 17:45:20 -0500
commitbab3c56a327edd9f9f4afe045a78cf68b84908ba (patch)
treecf186f523db36b790ed260519f693f2522bed972
parent21cf82b2fe379d6ba0bd4aabd5076370a3a04c49 (diff)
downloadmongo-bab3c56a327edd9f9f4afe045a78cf68b84908ba.tar.gz
SERVER-21099: Improve logging in Linux's SecureRandom
-rw-r--r--src/mongo/platform/random.cpp15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/mongo/platform/random.cpp b/src/mongo/platform/random.cpp
index d278cd9f8d0..99f7d94f85e 100644
--- a/src/mongo/platform/random.cpp
+++ b/src/mongo/platform/random.cpp
@@ -26,10 +26,12 @@
* delete this exception statement from all source files in the program,
* then also delete it in the license file.
*/
+#define MONGO_LOG_DEFAULT_COMPONENT ::mongo::logger::LogComponent::kDefault
+
+#include "mongo/platform/basic.h"
#include "mongo/platform/random.h"
-#include <stdio.h>
#include <string.h>
#ifndef _WIN32
@@ -38,10 +40,10 @@
#define _CRT_RAND_S
#include <cstdlib>
-#include <iostream>
#include <fstream>
+#include <iostream>
-#include "mongo/platform/basic.h"
+#include <mongo/util/log.h>
namespace mongo {
@@ -113,8 +115,8 @@ public:
InputStreamSecureRandom(const char* fn) {
_in = new std::ifstream(fn, std::ios::binary | std::ios::in);
if (!_in->is_open()) {
- std::cerr << "can't open " << fn << " " << strerror(errno) << std::endl;
- abort();
+ error() << "cannot open " << fn << " " << strerror(errno);
+ fassertFailed(28839);
}
}
@@ -126,7 +128,8 @@ public:
int64_t r;
_in->read(reinterpret_cast<char*>(&r), sizeof(r));
if (_in->fail()) {
- abort();
+ error() << "InputStreamSecureRandom failed to generate random bytes";
+ fassertFailed(28840);
}
return r;
}