summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDwight <dmerriman@gmail.com>2008-07-09 12:32:11 -0400
committerDwight <dmerriman@gmail.com>2008-07-09 12:32:11 -0400
commitee68a8e252224d3d771bc08c17078fb50e12d885 (patch)
tree8c9f14592b8dfd278ca03a7303f6b16baaa0665d
parent1bf45a0843ae3f28977f3a26a637c478ac557371 (diff)
downloadmongo-ee68a8e252224d3d771bc08c17078fb50e12d885.tar.gz
--nocursors
-rw-r--r--db/db.cpp8
-rw-r--r--db/db.vcproj4
-rw-r--r--db/jsobj.h2
-rw-r--r--db/pdfile.cpp8
-rw-r--r--db/query.cpp3
-rw-r--r--stdafx.cpp3
-rw-r--r--stdafx.h16
-rw-r--r--util/log.h37
-rw-r--r--util/mmap.cpp7
-rw-r--r--util/util.cpp2
10 files changed, 70 insertions, 20 deletions
diff --git a/db/db.cpp b/db/db.cpp
index 0a37b98c20a..53194a35059 100644
--- a/db/db.cpp
+++ b/db/db.cpp
@@ -16,6 +16,9 @@
extern const char *dbpath;
extern int curOp;
+/* only off if --nocursors which is for debugging. */
+bool useCursors = true;
+
boost::mutex dbMutex;
void closeAllSockets();
@@ -882,6 +885,8 @@ int main(int argc, char* argv[], char *envp[] )
else if (s && strcmp(s, "--appsrvpath") == 0) {
appsrvPath = argv[++i];
}
+ else if( s && strcmp(s, "--nocursors") == 0)
+ useCursors = false;
}
initAndListen(port, dbpath, appsrvPath);
@@ -900,7 +905,8 @@ int main(int argc, char* argv[], char *envp[] )
cout << " test2 run test2() - see code" << endl;
cout << " dev run in dev mode (diff db loc, diff port #)" << endl;
cout << endl << "Alternate Usage :" << endl;
- cout << " --port <portno> --dbpath <root> --appsrvpath <root of appsrv>" << endl << endl;
+ cout << " --port <portno> --dbpath <root> --appsrvpath <root of appsrv>" << endl;
+ cout << " --nocursors" << endl << endl;
goingAway = true;
return 0;
diff --git a/db/db.vcproj b/db/db.vcproj
index 5020802bb37..3e31c7b5bb1 100644
--- a/db/db.vcproj
+++ b/db/db.vcproj
@@ -289,6 +289,10 @@
>
</File>
<File
+ RelativePath="..\util\log.h"
+ >
+ </File>
+ <File
RelativePath="..\util\lruishmap.h"
>
</File>
diff --git a/db/jsobj.h b/db/jsobj.h
index 50cc3a55fd6..1620298ec0b 100644
--- a/db/jsobj.h
+++ b/db/jsobj.h
@@ -36,7 +36,7 @@ struct OID {
long long a;
unsigned b;
bool operator==(const OID& r) { return a==r.a&&b==r.b; }
- void out(){ cout << hex << a << hex << b << endl; };
+ void out(){ cout << hex << a << hex << b << endl; };
};
/* marshalled js object format:
diff --git a/db/pdfile.cpp b/db/pdfile.cpp
index 0f4f72e0b8d..e4167b91625 100644
--- a/db/pdfile.cpp
+++ b/db/pdfile.cpp
@@ -72,6 +72,11 @@ int bucketSizes[] = {
//NamespaceIndexMgr namespaceIndexMgr;
void NamespaceDetails::addDeletedRec(DeletedRecord *d, DiskLoc dloc) {
+ {
+ // defensive code: try to make us notice if we reference a deleted record
+ (unsigned&) (((Record *) d)->data) = 0xeeeeeeee;
+ }
+
dassert( dloc.drec() == d );
DEBUGGING cout << "TEMP: add deleted rec " << dloc.toString() << ' ' << hex << d->extentOfs << endl;
int b = bucket(d->lengthWithHeaders);
@@ -590,6 +595,9 @@ auto_ptr<Cursor> DataFileMgr::findAll(const char *ns) {
}
while( e->firstRecord.isNull() && !e->xnext.isNull() ) {
+ /* todo: if extent is empty, free it for reuse elsewhere.
+ that is a bit complicated have to clean up the freelists.
+ */
OCCASIONALLY cout << "info DFM::findAll(): extent " << loc.toString() << " was empty, skipping ahead" << endl;
// find a nonempty extent
// it might be nice to free the whole extent here! but have to clean up free recs then.
diff --git a/db/query.cpp b/db/query.cpp
index fd5491421f8..e09bb2d3fbe 100644
--- a/db/query.cpp
+++ b/db/query.cpp
@@ -21,6 +21,7 @@ const int MaxBytesToReturnToClientAtOnce = 4 * 1024 * 1024;
LRUishMap<JSObj,DiskLoc,5> lrutest(123);
int nextCursorId = 1;
+extern bool useCursors;
#pragma pack(push)
#pragma pack(1)
@@ -881,7 +882,7 @@ assert( debug.getN() < 5000 );
/* if only 1 requested, no cursor saved for efficiency...we assume it is findOne() */
if( wantMore && ntoreturn != 1 ) {
c->advance();
- if( c->ok() ) {
+ if( c->ok() && useCursors ) {
// more...so save a cursor
ClientCursor *cc = new ClientCursor();
cc->c = c;
diff --git a/stdafx.cpp b/stdafx.cpp
index c61f9d1ab85..35a718e2b66 100644
--- a/stdafx.cpp
+++ b/stdafx.cpp
@@ -23,7 +23,8 @@ void sayDbContext(const char *p = 0);
void wasserted(const char *msg, const char *file, unsigned line) {
problem() << "Assertion failure " << msg << ' ' << file << ' ' << line << endl;
cout << "Assertion failure " << msg << endl;
- cout << ' ' << file << ' ' << line << endl;
+ cout << ' ' << file << ' ';
+ cout << line << endl;
sayDbContext();
}
diff --git a/stdafx.h b/stdafx.h
index 5309cbd48a2..eb9d75adbf9 100644
--- a/stdafx.h
+++ b/stdafx.h
@@ -92,24 +92,10 @@ typedef struct _OWS {
char string[400];
} *OWS;
-//extern ofstream problems;
-
class Client;
extern Client *client;
extern const char *curNs;
-// not threadsafe
-inline ostream& problem() {
- ostream& problems = cout;
- time_t t;
- time(&t);
- string now(ctime(&t),0,20);
- problems << "~ " << now;
- if( client )
- problems << curNs << ' ';
- return problems;
-}
-
/* for now, running on win32 means development not production --
use this to log things just there.
*/
@@ -147,3 +133,5 @@ void dbexit(int resultcode);
using namespace boost::filesystem;
#include "util/goodies.h"
+#include "util/log.h"
+
diff --git a/util/log.h b/util/log.h
new file mode 100644
index 00000000000..90e7141706c
--- /dev/null
+++ b/util/log.h
@@ -0,0 +1,37 @@
+// log.h
+
+#pragma once
+
+class Nullstream {
+public:
+ Nullstream& operator<<(const char *) { return *this; }
+ Nullstream& operator<<(int) { return *this; }
+ Nullstream& operator<<(unsigned long) { return *this; }
+ Nullstream& operator<<(unsigned) { return *this; }
+ Nullstream& operator<<(double) { return *this; }
+ Nullstream& operator<<(void *) { return *this; }
+ Nullstream& operator<<(long long) { return *this; }
+ Nullstream& operator<<(unsigned long long) { return *this; }
+ Nullstream& operator<<(const string&) { return *this; }
+ Nullstream& operator<< (ostream& ( *endl )(ostream&)) { return *this; }
+ Nullstream& operator<< (ios_base& (*hex)(ios_base&)) { return *this; }
+};
+
+inline Nullstream& endl ( Nullstream& os ) { }
+
+extern Nullstream nullstream;
+
+//#define cout nullstream
+
+// not threadsafe
+inline ostream& problem() {
+ ostream& problems = cout;
+ time_t t;
+ time(&t);
+ string now(ctime(&t),0,20);
+ problems << "~ " << now;
+ if( client )
+ problems << curNs << ' ';
+ return problems;
+}
+
diff --git a/util/mmap.cpp b/util/mmap.cpp
index ab814f61f80..e29dcc6b6f3 100644
--- a/util/mmap.cpp
+++ b/util/mmap.cpp
@@ -80,8 +80,11 @@ void* MemoryMappedFile::map(const char *filename, int length) {
}
view = MapViewOfFile(maphandle, FILE_MAP_ALL_ACCESS, 0, 0, 0);
- if( view == 0 )
- cout << "MapViewOfFile failed " << filename << " errno:" << GetLastError() << endl;
+ if( view == 0 ) {
+ cout << "MapViewOfFile failed " << filename << " errno:";
+ cout << GetLastError();
+ cout << endl;
+ }
return view;
}
diff --git a/util/util.cpp b/util/util.cpp
index 92e0edb7423..ddb96921ef5 100644
--- a/util/util.cpp
+++ b/util/util.cpp
@@ -1,6 +1,8 @@
#include "stdafx.h"
#include "goodies.h"
+Nullstream nullstream;
+
unsigned occasion = 0;
bool goingAway = false;