summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--db/db.cpp22
-rw-r--r--db/repl.cpp4
-rw-r--r--dbgrid/dbgrid.cpp29
3 files changed, 48 insertions, 7 deletions
diff --git a/db/db.cpp b/db/db.cpp
index c2b6b62fd61..1ef144abf73 100644
--- a/db/db.cpp
+++ b/db/db.cpp
@@ -58,10 +58,17 @@ struct MyStartupTests {
*/
int opLogging = 0;
+// turn on or off the oplog.* files which the db can generate.
+// these files are for diagnostic purposes and are unrelated to
+// local.oplog.$main used by replication.
+//
+#define OPLOG if( 0 )
+
struct OpLog {
ofstream *f;
OpLog() : f(0) { }
void init() {
+ OPLOG {
stringstream ss;
ss << "oplog." << hex << time(0);
string name = ss.str();
@@ -70,17 +77,26 @@ struct OpLog {
problem() << "couldn't open log stream" << endl;
throw 1717;
}
+ }
}
+ void flush() {
+ OPLOG f->flush();
+ }
+ void write(char *data,int len) {
+ OPLOG f->write(data,len);
+ }
void readop(char *data, int len) {
+ OPLOG {
bool log = (opLogging & 4) == 0;
OCCASIONALLY log = true;
if( log )
f->write(data,len);
+ }
}
} _oplog;
-void flushOpLog() { _oplog.f->flush(); }
-#define oplog (*(_oplog.f))
-#define OPWRITE if( opLogging & 1 ) oplog.write((char *) m.data, m.data->len);
+void flushOpLog() { _oplog.flush(); }
+//#define oplog (*(_oplog.f))
+#define OPWRITE if( opLogging & 1 ) _oplog.write((char *) m.data, m.data->len);
#define OPREAD if( opLogging & 2 ) _oplog.readop((char *) m.data, m.data->len);
/* example for
diff --git a/db/repl.cpp b/db/repl.cpp
index dd0b411e659..b5c456afbd6 100644
--- a/db/repl.cpp
+++ b/db/repl.cpp
@@ -51,7 +51,7 @@ ReplPair *replPair = 0;
JSObj ismasterobj = fromjson("{ismaster:1}");
-/* peer unreachable, try our arbitrator */
+/* peer unreachable, try our arbiter */
void ReplPair::arbitrate() {
if( arbHost == "-" ) {
// no arbiter. we are up, let's assume he is down and network is not partitioned.
@@ -72,7 +72,7 @@ void ReplPair::arbitrate() {
return;
}
- setMaster(State_Master, "remote down, arbitrator reached");
+ setMaster(State_Master, "remote down, arbiter reached");
}
/* --------------------------------------------- */
diff --git a/dbgrid/dbgrid.cpp b/dbgrid/dbgrid.cpp
index 03e6fbe80c2..5efaa19c803 100644
--- a/dbgrid/dbgrid.cpp
+++ b/dbgrid/dbgrid.cpp
@@ -43,15 +43,40 @@ void pipeSigHandler( int signal ) {
void setupSignals() {}
#endif
+void usage() {
+ cout << "Mongo dbgrid usage:\n";
+ cout << " --port <portno>\n";
+ cout << endl;
+}
+
+int port = 0;
+
+void start() {
+}
+
int main(int argc, char* argv[], char *envp[] ) {
#if !defined(_WIN32)
signal(SIGPIPE, pipeSigHandler);
#endif
- log() << "dbgrid starting" << endl;
+ for (int i = 1; i < argc; i++) {
+ if( argv[i] == 0 ) continue;
+ string s = argv[i];
+ if( s == "--port" ) {
+ port = atoi(argv[++i]);
+ }
+ }
- UnitTest::runTests();
+ bool ok = port != 0;
+
+ if( !ok ) {
+ usage();
+ return 1;
+ }
+ log() << "dbgrid starting" << endl;
+ UnitTest::runTests();
+ start();
dbexit(0);
return 0;
}