[Tarantool-patches] [PATCH 03/17] recovery: recovery_close_log -- don't throw exception

Vladislav Shpilevoy v.shpilevoy at tarantool.org
Sun May 3 21:43:08 MSK 2020


Thanks for the patch!

> 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;
>  }

Seems like you could avoid almost all these changes by simply
this:

====================
-static inline void
+static int
 recovery_close_log(struct recovery *r)
 {
 	if (!xlog_cursor_is_open(&r->cursor))
-		return;
+		return 0;
 	if (xlog_cursor_is_eof(&r->cursor)) {
 		say_info("done `%s'", r->cursor.name);
 	} else {
@@ -156,7 +156,7 @@ recovery_close_log(struct recovery *r)
 			 r->cursor.name);
 	}
 	xlog_cursor_close(&r->cursor, false);
-	trigger_run_xc(&r->on_close_log, NULL);
+	return trigger_run(&r->on_close_log, NULL);
 }

====================

Why so complex?


More information about the Tarantool-patches mailing list