From f699cf17ae829b4cef9759dcf19c116dd4ab09ef Mon Sep 17 00:00:00 2001 From: "Raphael S. Carvalho" Date: Tue, 28 Nov 2017 23:49:17 -0200 Subject: [PATCH] sstables: fix data_consume_context's move operator and ctor after 7f8b62bc0b87, 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 Message-Id: <20171129014917.11841-1-raphaelsc@scylladb.com> --- sstables/row.cc | 10 +++------- sstables/sstables.hh | 2 -- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/sstables/row.cc b/sstables/row.cc index b879c64c53..0b04dad730 100644 --- a/sstables/row.cc +++ b/sstables/row.cc @@ -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&& input, uint64_t start, uint64_t maxlen) : _sst(std::move(sst)), _ctx(new data_consume_rows_context(consumer, std::move(input), start, maxlen)) { } diff --git a/sstables/sstables.hh b/sstables/sstables.hh index cfb5168228..b68d4426cd 100644 --- a/sstables/sstables.hh +++ b/sstables/sstables.hh @@ -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;