From be9e419a3257ba10b95bc36a6808574ee3a56618 Mon Sep 17 00:00:00 2001 From: Glauber Costa Date: Fri, 18 Nov 2016 08:56:01 -0500 Subject: [PATCH] commitlog: close file after read, and not at stop There are other code paths that may interrupt the read in the middle and bypass stop. It's safer this way. Signed-off-by: Glauber Costa Message-Id: <8c32ca2777ce2f44462d141fd582848ac7cf832d.1479477360.git.glauber@scylladb.com> (cherry picked from commit 60b7d35f15c475df3eacae3afc469e56651cffc5) --- db/commitlog/commitlog.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/db/commitlog/commitlog.cc b/db/commitlog/commitlog.cc index 87f7052f72..afe2b5d115 100644 --- a/db/commitlog/commitlog.cc +++ b/db/commitlog/commitlog.cc @@ -1601,7 +1601,7 @@ db::commitlog::read_log_file(file f, commit_load_reader_func next, position_type } future<> stop() { eof = true; - return fin.close(); + return make_ready_future<>(); } future<> read_header() { return fin.read_exactly(segment::descriptor_header_size).then([this](temporary_buffer buf) { @@ -1755,6 +1755,8 @@ db::commitlog::read_log_file(file f, commit_load_reader_func next, position_type throw segment_data_corruption_error("Data corruption", corrupt_size); } }); + }).finally([this] { + return fin.close(); }); } };