Operations on a segment's underlying append_challenged_posix_file_impl, such as truncate(), schedule asynchronous operations when they are executed, which capture the file object. To synchronize with them and prevent use-after-free, we need to call close() and only delete the segment and file when the returned future resolves. Signed-off-by: Duarte Nunes <duarte@scylladb.com> Message-Id: <20180216235754.24257-1-duarte@scylladb.com>