diff options
Diffstat (limited to 'src/mongo/rpc/op_msg.cpp')
-rw-r--r-- | src/mongo/rpc/op_msg.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/mongo/rpc/op_msg.cpp b/src/mongo/rpc/op_msg.cpp index f886027e192..9199693b0e0 100644 --- a/src/mongo/rpc/op_msg.cpp +++ b/src/mongo/rpc/op_msg.cpp @@ -247,4 +247,15 @@ Message OpMsgBuilder::finish() { return Message(_buf.release()); } +BSONObj OpMsgBuilder::releaseBody() { + invariant(_state == kBody); + invariant(_bodyStart); + invariant(_bodyStart == sizeof(MSGHEADER::Layout) + 4 /*flags*/ + 1 /*body kind byte*/); + invariant(!_openBuilder); + _state = kDone; + + auto bson = BSONObj(_buf.buf() + _bodyStart); + return bson.shareOwnershipWith(_buf.release()); +} + } // namespace mongo |