summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDwight <dmerriman@gmail.com>2008-06-17 16:57:12 -0400
committerDwight <dmerriman@gmail.com>2008-06-17 16:57:12 -0400
commit652faabd1854bac70edc5b7976065ea0a2af4f22 (patch)
tree60735110ac4be3a9d4793753149084bad916882d
parent1d8c3e37b32a11d2e2b64fee019782f5efdd19c6 (diff)
downloadmongo-652faabd1854bac70edc5b7976065ea0a2af4f22.tar.gz
catch exception on getMore()
-rw-r--r--db/db.cpp11
-rw-r--r--db/query.cpp20
-rw-r--r--stdafx.h10
3 files changed, 35 insertions, 6 deletions
diff --git a/db/db.cpp b/db/db.cpp
index 67cf5d15dd6..43168d0007f 100644
--- a/db/db.cpp
+++ b/db/db.cpp
@@ -201,6 +201,8 @@ void receivedQuery(AbstractMessagingPort& dbMsgPort, Message& m, stringstream& s
dbMsgPort.reply(m, resp, responseTo);
}
+QueryResult* emptyMoreResult(long long);
+
void receivedGetMore(AbstractMessagingPort& dbMsgPort, Message& m, stringstream& ss) {
DbMessage d(m);
const char *ns = d.getns();
@@ -210,7 +212,14 @@ void receivedGetMore(AbstractMessagingPort& dbMsgPort, Message& m, stringstream&
long long cursorid = d.pullInt64();
ss << " cid:" << cursorid;
ss << " ntoreturn:" << ntoreturn;
- QueryResult* msgdata = getMore(ns, ntoreturn, cursorid);
+ QueryResult* msgdata;
+ try {
+ msgdata = getMore(ns, ntoreturn, cursorid);
+ }
+ catch( AssertionException ) {
+ ss << " exception ";
+ msgdata = emptyMoreResult(cursorid);
+ }
Message resp;
resp.setData(msgdata, true);
ss << " bytes:" << resp.data->dataLen();
diff --git a/db/query.cpp b/db/query.cpp
index 47254c97b0b..d7f2d42d20e 100644
--- a/db/query.cpp
+++ b/db/query.cpp
@@ -784,13 +784,23 @@ assert( debug.getN() < 5000 );
return qr;
}
-int dump = 0;
+//int dump = 0;
-QueryResult* getMore(const char *ns, int ntoreturn, long long cursorid) {
-
-// cout << "getMore ns:" << ns << " ntoreturn:" << ntoreturn << " cursorid:" <<
-// cursorid << endl;
+/* empty result for error conditions */
+QueryResult* emptyMoreResult(long long cursorid) {
+ BufBuilder b(32768);
+ b.skip(sizeof(QueryResult));
+ QueryResult *qr = (QueryResult *) b.buf();
+ qr->cursorId = cursorid;
+ qr->startingFrom = 0;
+ qr->len = b.len();
+ qr->operation = opReply;
+ qr->nReturned = 0;
+ b.decouple();
+ return qr;
+}
+QueryResult* getMore(const char *ns, int ntoreturn, long long cursorid) {
BufBuilder b(32768);
ClientCursor *cc = ClientCursor::find(cursorid);
diff --git a/stdafx.h b/stdafx.h
index 8253751833d..b8af6352305 100644
--- a/stdafx.h
+++ b/stdafx.h
@@ -119,3 +119,13 @@ inline ostream& problem() {
extern unsigned occasion;
#define OCCASIONALLY if( ++occasion % 16 == 0 )
+
+#if defined(_WIN32)
+inline void our_debug_free(void *p) {
+ unsigned *u = (unsigned *) p;
+ u[0] = 0xEEEEEEEE;
+ u[1] = 0xEEEEEEEE;
+ free(p);
+}
+#define free our_debug_free
+#endif