sstables: fix data_consume_context's move operator and ctor

after 7f8b62bc0b, its move operator and ctor broke. That potentially
leads to error because data_consume_context dtor moves sstable ref
to continuation when waiting for in-flight reads from input stream.
Otherwise, sstable can be destroyed meanwhile and file descriptor
would be invalid, leading to EBADF.

Fixes #3020.

Signed-off-by: Raphael S. Carvalho <raphaelsc@scylladb.com>
Message-Id: <20171129014917.11841-1-raphaelsc@scylladb.com>
This commit is contained in:
Raphael S. Carvalho
2017-11-28 23:49:17 -02:00
committed by Tomasz Grabiec
parent 4cfcd8055e
commit f699cf17ae
2 changed files with 3 additions and 9 deletions

View File

@@ -393,13 +393,9 @@ data_consume_context::~data_consume_context() {
f.handle_exception([ctx = std::move(_ctx), sst = std::move(_sst)](auto) {});
}
};
data_consume_context::data_consume_context(data_consume_context&& o) noexcept
: _ctx(std::move(o._ctx))
{ }
data_consume_context& data_consume_context::operator=(data_consume_context&& o) noexcept {
_ctx = std::move(o._ctx);
return *this;
}
data_consume_context::data_consume_context(data_consume_context&& o) noexcept = default;
data_consume_context& data_consume_context::operator=(data_consume_context&& o) noexcept = default;
data_consume_context::data_consume_context(shared_sstable sst, row_consumer& consumer, input_stream<char>&& input, uint64_t start, uint64_t maxlen)
: _sst(std::move(sst)), _ctx(new data_consume_rows_context(consumer, std::move(input), start, maxlen))
{ }

View File

@@ -105,8 +105,6 @@ public:
future<> skip_to(indexable_element, uint64_t begin);
uint64_t position() const;
bool eof() const;
// Define (as defaults) the destructor and move operations in the source
// file, so here we don't need to know the incomplete impl type.
~data_consume_context();
data_consume_context(data_consume_context&&) noexcept;
data_consume_context& operator=(data_consume_context&&) noexcept;