summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDwight <dmerriman@gmail.com>2008-06-23 16:28:25 -0400
committerDwight <dmerriman@gmail.com>2008-06-23 16:28:25 -0400
commitcb18407a0d3dccfb910aa4ef9afb1aabb627bcc9 (patch)
tree47586a86e0e9ab2722c3be264e7b92f15b68f947
parent5d2cdfbad07ca56bef939b44eea3599cbd043835 (diff)
downloadmongo-cb18407a0d3dccfb910aa4ef9afb1aabb627bcc9.tar.gz
replay better
-rw-r--r--db/db.cpp29
-rw-r--r--db/db.vcproj2
-rw-r--r--db/query.cpp4
-rw-r--r--stdafx.h3
4 files changed, 31 insertions, 7 deletions
diff --git a/db/db.cpp b/db/db.cpp
index 22741227c77..d504ef9e1e1 100644
--- a/db/db.cpp
+++ b/db/db.cpp
@@ -289,7 +289,7 @@ public:
115 replay, opLogging
*/
void listen(int port) {
- const char *Version = "db version: 115 18jun2008";
+ const char *Version = "db version: 116 23jun2008";
problem() << Version << endl;
cout << Version << endl;
pdfileInit();
@@ -418,8 +418,19 @@ void jniCallback(Message& m, Message& out)
}
/* 0 = off; 1 = writes, 2 = reads, 3 = both */
-int opLogging = 0;
-ofstream oplog("oplog.bin", ios::out | ios::binary);
+int opLogging = 1;
+//int opLogging = 0;
+struct OpLog {
+ ofstream *f;
+ OpLog() {
+ stringstream ss;
+ ss << "oplog." << hex << time(0);
+ string name = ss.str();
+ f = new ofstream(name.c_str(), ios::out | ios::binary);
+ }
+} _oplog;
+void flushOpLog() { _oplog.f->flush(); }
+#define oplog (*(_oplog.f))
#define OPWRITE if( opLogging & 1 ) oplog.write((char *) m.data, m.data->len);
#define OPREAD if( opLogging & 2 ) oplog.write((char *) m.data, m.data->len);
@@ -690,6 +701,9 @@ void initAndListen(int listenPort, const char *dbPath, const char *appserverLoc
int main(int argc, char* argv[], char *envp[] )
{
+ if( opLogging )
+ cout << "WARNING: this build has oplog enabled at startup. opLogging=" << opLogging << endl;
+
#if !defined(_WIN32)
signal(SIGPIPE, pipeSigHandler);
#endif
@@ -778,7 +792,7 @@ int main(int argc, char* argv[], char *envp[] )
initAndListen(port, dbpath, appsrvPath);
goingAway = true;
- return 0;
+ exit(0);
}
cout << "usage:\n";
@@ -801,3 +815,10 @@ int main(int argc, char* argv[], char *envp[] )
// return _tmain(argc, 0);
//}
//#endif
+
+#undef exit
+void dbexit(int rc) {
+ flushOpLog();
+ exit(rc);
+}
+
diff --git a/db/db.vcproj b/db/db.vcproj
index a8c8d43b35b..cf4ae689310 100644
--- a/db/db.vcproj
+++ b/db/db.vcproj
@@ -43,7 +43,7 @@
<Tool
Name="VCCLCompilerTool"
Optimization="0"
- AdditionalIncludeDirectories="&quot;C:\Program Files\Java\jdk1.6.0_05\include&quot;;&quot;C:\Program Files\Java\jdk1.6.0_05\include\win32&quot;"
+ AdditionalIncludeDirectories="&quot;..\pcre-7.4&quot;;..\boost;&quot;C:\Program Files\Java\jdk1.6.0_05\include&quot;;&quot;C:\Program Files\Java\jdk1.6.0_05\include\win32&quot;"
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;_SCL_SECURE_NO_DEPRECATE;BOOST_ALL_NO_LIB;BOOST_LIB_DIAGNOSTIC;_CRT_SECURE_NO_WARNINGS;HAVE_CONFIG_H"
MinimalRebuild="true"
BasicRuntimeChecks="3"
diff --git a/db/query.cpp b/db/query.cpp
index cf066b4275f..a0e445c3041 100644
--- a/db/query.cpp
+++ b/db/query.cpp
@@ -458,7 +458,7 @@ bool dbEval(JSObj& cmd, JSObjBuilder& result) {
}
extern int opLogging;
-extern ofstream oplog;
+void flushOpLog();
// e.g.
// system.cmd$.find( { queryTraceLevel: 2 } );
@@ -506,7 +506,7 @@ inline bool _runCommands(const char *ns, JSObj& jsobj, stringstream& ss, BufBuil
if( strcmp(e.fieldName(),"opLogging") == 0 ) {
valid = ok = true;
opLogging = (int) e.number();
- oplog.flush();
+ flushOpLog();
cout << "CMD: opLogging set to " << opLogging << endl;
} else if( strcmp(e.fieldName(),"queryTraceLevel") == 0 ) {
valid = ok = true;
diff --git a/stdafx.h b/stdafx.h
index b8af6352305..c2c22de0f03 100644
--- a/stdafx.h
+++ b/stdafx.h
@@ -129,3 +129,6 @@ inline void our_debug_free(void *p) {
}
#define free our_debug_free
#endif
+
+void dbexit(int resultcode);
+#define exit dbexit