diff options
author | Adam Midvidy <amidvidy@gmail.com> | 2015-06-15 14:15:15 -0400 |
---|---|---|
committer | Adam Midvidy <amidvidy@gmail.com> | 2015-06-16 16:25:39 -0400 |
commit | d124312c4c7d34678565a2607d13a016279b9893 (patch) | |
tree | 984bc36ef408e4b961a285e88a510a99f77e35b0 /src/mongo/rpc/legacy_reply_builder.cpp | |
parent | 49c54afb7abfeceb0f9f03ed59df69b9cf22a5e7 (diff) | |
download | mongo-d124312c4c7d34678565a2607d13a016279b9893.tar.gz |
SERVER-18236 fix exception safety in generateErrorResponse
Diffstat (limited to 'src/mongo/rpc/legacy_reply_builder.cpp')
-rw-r--r-- | src/mongo/rpc/legacy_reply_builder.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/mongo/rpc/legacy_reply_builder.cpp b/src/mongo/rpc/legacy_reply_builder.cpp index 69134af3628..e95c6ceff8b 100644 --- a/src/mongo/rpc/legacy_reply_builder.cpp +++ b/src/mongo/rpc/legacy_reply_builder.cpp @@ -86,6 +86,18 @@ namespace rpc { return rpc::Protocol::kOpQuery; } + void LegacyReplyBuilder::reset() { + // If we are in State::kMetadata, we are already in the 'start' state, so by + // immediately returning, we save a heap allocation. + if (_state == State::kMetadata) { + return; + } + _builder.reset(); + _metadata = BSONObj(); + _message = stdx::make_unique<Message>(); + _state = State::kMetadata; + } + std::unique_ptr<Message> LegacyReplyBuilder::done() { invariant(_state == State::kOutputDocs); std::unique_ptr<Message> message = stdx::make_unique<Message>(); |