diff options
author | Dwight <dmerriman@gmail.com> | 2008-06-23 16:28:25 -0400 |
---|---|---|
committer | Dwight <dmerriman@gmail.com> | 2008-06-23 16:28:25 -0400 |
commit | cb18407a0d3dccfb910aa4ef9afb1aabb627bcc9 (patch) | |
tree | 47586a86e0e9ab2722c3be264e7b92f15b68f947 | |
parent | 5d2cdfbad07ca56bef939b44eea3599cbd043835 (diff) | |
download | mongo-cb18407a0d3dccfb910aa4ef9afb1aabb627bcc9.tar.gz |
replay better
-rw-r--r-- | db/db.cpp | 29 | ||||
-rw-r--r-- | db/db.vcproj | 2 | ||||
-rw-r--r-- | db/query.cpp | 4 | ||||
-rw-r--r-- | stdafx.h | 3 |
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=""C:\Program Files\Java\jdk1.6.0_05\include";"C:\Program Files\Java\jdk1.6.0_05\include\win32""
+ AdditionalIncludeDirectories=""..\pcre-7.4";..\boost;"C:\Program Files\Java\jdk1.6.0_05\include";"C:\Program Files\Java\jdk1.6.0_05\include\win32""
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; @@ -129,3 +129,6 @@ inline void our_debug_free(void *p) { } #define free our_debug_free #endif + +void dbexit(int resultcode); +#define exit dbexit |