From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lj1-f196.google.com (mail-lj1-f196.google.com [209.85.208.196]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id 2AA234696C4 for ; Tue, 28 Apr 2020 19:12:37 +0300 (MSK) Received: by mail-lj1-f196.google.com with SMTP id a21so19199794ljj.11 for ; Tue, 28 Apr 2020 09:12:37 -0700 (PDT) From: Cyrill Gorcunov Date: Tue, 28 Apr 2020 19:11:23 +0300 Message-Id: <20200428161137.20536-4-gorcunov@gmail.com> In-Reply-To: <20200428161137.20536-1-gorcunov@gmail.com> References: <20200428161137.20536-1-gorcunov@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [Tarantool-patches] [PATCH 03/17] recovery: recovery_close_log -- don't throw exception List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: tml Prepare for transition to plain C Signed-off-by: Cyrill Gorcunov --- src/box/recovery.cc | 35 +++++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/src/box/recovery.cc b/src/box/recovery.cc index 76b771a91..16e38cee2 100644 --- a/src/box/recovery.cc +++ b/src/box/recovery.cc @@ -144,19 +144,22 @@ recovery_scan(struct recovery *r, struct vclock *end_vclock, xlog_cursor_close(&cursor, false); } -static inline void +static int recovery_close_log(struct recovery *r) { - if (!xlog_cursor_is_open(&r->cursor)) - return; - if (xlog_cursor_is_eof(&r->cursor)) { - say_info("done `%s'", r->cursor.name); - } else { - say_warn("file `%s` wasn't correctly closed", - r->cursor.name); + if (xlog_cursor_is_open(&r->cursor)) { + if (xlog_cursor_is_eof(&r->cursor)) { + say_info("done `%s'", r->cursor.name); + } else { + say_warn("file `%s` wasn't correctly closed", + r->cursor.name); + } + xlog_cursor_close(&r->cursor, false); + + if (trigger_run(&r->on_close_log, NULL) != 0) + return -1; } - xlog_cursor_close(&r->cursor, false); - trigger_run_xc(&r->on_close_log, NULL); + return 0; } static void @@ -166,7 +169,8 @@ recovery_open_log(struct recovery *r, const struct vclock *vclock) struct xlog_meta meta = r->cursor.meta; enum xlog_cursor_state state = r->cursor.state; - recovery_close_log(r); + if (recovery_close_log(r) != 0) + diag_raise(); xdir_open_cursor_xc(&r->wal_dir, vclock_sum(vclock), &r->cursor); @@ -349,8 +353,10 @@ recover_remaining_wals(struct recovery *r, struct xstream *stream, recover_xlog(r, stream, stop_vclock); } - if (xlog_cursor_is_eof(&r->cursor)) - recovery_close_log(r); + if (xlog_cursor_is_eof(&r->cursor)) { + if (recovery_close_log(r) != 0) + diag_raise(); + } if (stop_vclock != NULL && vclock_compare(&r->vclock, stop_vclock) != 0) tnt_raise(XlogGapError, &r->vclock, stop_vclock); @@ -361,7 +367,8 @@ recover_remaining_wals(struct recovery *r, struct xstream *stream, void recovery_finalize(struct recovery *r) { - recovery_close_log(r); + if (recovery_close_log(r) != 0) + diag_raise(); } -- 2.20.1