diff options
-rw-r--r-- | db/db.cpp | 11 | ||||
-rw-r--r-- | db/query.cpp | 20 | ||||
-rw-r--r-- | stdafx.h | 10 |
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); @@ -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 |