Make streamed_mutation more exception safe

Make sure that push_mutation_fragment leaves
_buffer_size with a correct value if exception
is thrown from emplace_back.

Signed-off-by: Piotr Jastrzebski <piotr@scylladb.com>
Message-Id: <83398412aa78332d88d91336b79140aecc988602.1503474403.git.piotr@scylladb.com>
(cherry picked from commit 477068d2c3)
This commit is contained in:
Piotr Jastrzebski
2017-08-23 09:46:57 +02:00
committed by Avi Kivity
parent 29baf7966c
commit a98e3aec45

View File

@@ -422,9 +422,8 @@ public:
protected:
template<typename... Args>
void push_mutation_fragment(Args&&... args) {
auto mf = mutation_fragment(std::forward<Args>(args)...);
_buffer_size += mf.memory_usage();
_buffer.emplace_back(std::move(mf));
_buffer.emplace_back(std::forward<Args>(args)...);
_buffer_size += _buffer.back().memory_usage();
}
public:
explicit impl(schema_ptr s, dht::decorated_key dk, tombstone pt)