summaryrefslogtreecommitdiff
path: root/src/mongo/db/dbmessage.cpp
diff options
context:
space:
mode:
authorRandolph Tan <randolph@10gen.com>2012-05-14 10:05:51 -0400
committerRandolph Tan <randolph@10gen.com>2012-05-22 10:50:53 -0400
commit4a9a294376f6d4d599244154e0b1e49d0172aed7 (patch)
tree604fd8bde8133970b2039b588a8548414c70690e /src/mongo/db/dbmessage.cpp
parent13a9b34ae4ff54c29d2aac485168b6c6f4c77da9 (diff)
downloadmongo-4a9a294376f6d4d599244154e0b1e49d0172aed7.tar.gz
SERVER-5797 Uncaught exception in count_slaveok.js
Rewrote the count command in mongos to use ShardStrategy::commandOP and push handling of StaleConfigException to the caller. Also modified ParallelSortClusteredCursor to handle SyncClusterConnection not allowing the call method to be used on commands.
Diffstat (limited to 'src/mongo/db/dbmessage.cpp')
-rw-r--r--src/mongo/db/dbmessage.cpp33
1 files changed, 19 insertions, 14 deletions
diff --git a/src/mongo/db/dbmessage.cpp b/src/mongo/db/dbmessage.cpp
index 00743d4910f..2e0edf4dc9a 100644
--- a/src/mongo/db/dbmessage.cpp
+++ b/src/mongo/db/dbmessage.cpp
@@ -83,25 +83,30 @@ namespace mongo {
(void *) responseObj.objdata(), responseObj.objsize(), 1);
}
- void replyToQuery(int queryResultFlags, Message &m, DbResponse &dbresponse, BSONObj obj) {
- BufBuilder b;
- b.skip(sizeof(QueryResult));
- b.appendBuf((void*) obj.objdata(), obj.objsize());
- QueryResult* msgdata = (QueryResult *) b.buf();
- b.decouple();
- QueryResult *qr = msgdata;
- qr->_resultFlags() = queryResultFlags;
- qr->len = b.len();
- qr->setOperation(opReply);
- qr->cursorId = 0;
- qr->startingFrom = 0;
- qr->nReturned = 1;
+ void replyToQuery( int queryResultFlags, Message &m, DbResponse &dbresponse, BSONObj obj ) {
Message *resp = new Message();
- resp->setData(msgdata, true); // transport will free
+ replyToQuery( queryResultFlags, *resp, obj );
dbresponse.response = resp;
dbresponse.responseTo = m.header()->id;
}
+ void replyToQuery( int queryResultFlags, Message& response, const BSONObj& resultObj ) {
+ BufBuilder bufBuilder;
+ bufBuilder.skip( sizeof( QueryResult ));
+ bufBuilder.appendBuf( reinterpret_cast< void *>(
+ const_cast< char* >( resultObj.objdata() )), resultObj.objsize() );
+
+ QueryResult* queryResult = reinterpret_cast< QueryResult* >( bufBuilder.buf() );
+ bufBuilder.decouple();
+ queryResult->_resultFlags() = queryResultFlags;
+ queryResult->len = bufBuilder.len();
+ queryResult->setOperation( opReply );
+ queryResult->cursorId = 0;
+ queryResult->startingFrom = 0;
+ queryResult->nReturned = 1;
+
+ response.setData( queryResult, true ); // transport will free
+ }
}