From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTP id A5BC0273DE for ; Fri, 23 Aug 2019 05:59:39 -0400 (EDT) Received: from turing.freelists.org ([127.0.0.1]) by localhost (turing.freelists.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 1hDqjzeFTIep for ; Fri, 23 Aug 2019 05:59:39 -0400 (EDT) Received: from smtpng3.m.smailru.net (smtpng3.m.smailru.net [94.100.177.149]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTPS id 098B4252FE for ; Fri, 23 Aug 2019 05:59:38 -0400 (EDT) From: Kirill Shcherbatov Subject: [tarantool-patches] [PATCH v2 2/3] box: rename diag_add_error to diag_set_error Date: Fri, 23 Aug 2019 12:59:29 +0300 Message-Id: <4f87bd09c9b37de0ec1e1b57f46923bae16a64cf.1566553968.git.kshcherbatov@tarantool.org> In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: tarantool-patches-bounce@freelists.org Errors-to: tarantool-patches-bounce@freelists.org Reply-To: tarantool-patches@freelists.org List-Help: List-Unsubscribe: List-software: Ecartis version 1.0.0 List-Id: tarantool-patches List-Subscribe: List-Owner: List-post: List-Archive: To: tarantool-patches@freelists.org, georgy@tarantool.org Cc: alexander.turenko@tarantool.org, kostja@tarantool.org, Kirill Shcherbatov Renamed function diag_add_error to diag_set_error because it actually replaces an error object in diagnostic area with a new one and this name is not representative. Moreover, we are going to introduce a new diag_add_error that extends error object in diagnostic area in following patches. Needed for #1148 --- src/lib/core/diag.h | 6 +++--- src/lib/core/exception.h | 2 +- src/box/vy_scheduler.c | 6 +++--- src/lua/utils.c | 2 +- src/box/applier.cc | 2 +- src/box/error.cc | 2 +- src/box/relay.cc | 4 ++-- src/lib/core/exception.cc | 2 +- 8 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/lib/core/diag.h b/src/lib/core/diag.h index fd3831e66..02a67269f 100644 --- a/src/lib/core/diag.h +++ b/src/lib/core/diag.h @@ -162,12 +162,12 @@ diag_clear(struct diag *diag) } /** - * Add a new error to the diagnostics area + * Set a new error to the diagnostics area, replacing existent. * \param diag diagnostics area * \param e error to add */ static inline void -diag_add_error(struct diag *diag, struct error *e) +diag_set_error(struct diag *diag, struct error *e) { assert(e != NULL); error_ref(e); @@ -269,7 +269,7 @@ BuildSocketError(const char *file, unsigned line, const char *socketname, say_debug("%s at %s:%i", #class, __FILE__, __LINE__); \ struct error *e; \ e = Build##class(__FILE__, __LINE__, ##__VA_ARGS__); \ - diag_add_error(diag_get(), e); \ + diag_set_error(diag_get(), e); \ /* Restore the errno which might have been reset. */ \ errno = save_errno; \ } while (0) diff --git a/src/lib/core/exception.h b/src/lib/core/exception.h index a29281427..e1a45b3fb 100644 --- a/src/lib/core/exception.h +++ b/src/lib/core/exception.h @@ -182,7 +182,7 @@ exception_init(); #define tnt_error(class, ...) ({ \ say_debug("%s at %s:%i", #class, __FILE__, __LINE__); \ class *e = new class(__FILE__, __LINE__, ##__VA_ARGS__); \ - diag_add_error(diag_get(), e); \ + diag_set_error(diag_get(), e); \ e; \ }) diff --git a/src/box/vy_scheduler.c b/src/box/vy_scheduler.c index ee361c31f..31d144cf3 100644 --- a/src/box/vy_scheduler.c +++ b/src/box/vy_scheduler.c @@ -618,7 +618,7 @@ vy_scheduler_dump(struct vy_scheduler *scheduler) if (scheduler->is_throttled) { /* Dump error occurred. */ struct error *e = diag_last_error(&scheduler->diag); - diag_add_error(diag_get(), e); + diag_set_error(diag_get(), e); return -1; } fiber_cond_wait(&scheduler->dump_cond); @@ -692,7 +692,7 @@ vy_scheduler_begin_checkpoint(struct vy_scheduler *scheduler) */ if (scheduler->is_throttled) { struct error *e = diag_last_error(&scheduler->diag); - diag_add_error(diag_get(), e); + diag_set_error(diag_get(), e); say_error("cannot checkpoint vinyl, " "scheduler is throttled with: %s", e->errmsg); return -1; @@ -728,7 +728,7 @@ vy_scheduler_wait_checkpoint(struct vy_scheduler *scheduler) if (scheduler->is_throttled) { /* A dump error occurred, abort checkpoint. */ struct error *e = diag_last_error(&scheduler->diag); - diag_add_error(diag_get(), e); + diag_set_error(diag_get(), e); say_error("vinyl checkpoint failed: %s", e->errmsg); return -1; } diff --git a/src/lua/utils.c b/src/lua/utils.c index 75efe0ed2..22b0f0424 100644 --- a/src/lua/utils.c +++ b/src/lua/utils.c @@ -1004,7 +1004,7 @@ luaT_toerror(lua_State *L) struct error *e = luaL_iserror(L, -1); if (e != NULL) { /* Re-throw original error */ - diag_add_error(&fiber()->diag, e); + diag_set_error(&fiber()->diag, e); } else { /* Convert Lua error to a Tarantool exception. */ diag_set(LuajitError, luaT_tolstring(L, -1, NULL)); diff --git a/src/box/applier.cc b/src/box/applier.cc index 4304ff055..d34086681 100644 --- a/src/box/applier.cc +++ b/src/box/applier.cc @@ -762,7 +762,7 @@ applier_on_rollback(struct trigger *trigger, void *event) struct applier *applier = (struct applier *)trigger->data; /* Setup a shared error. */ if (!diag_is_empty(&replicaset.applier.diag)) { - diag_add_error(&applier->diag, + diag_set_error(&applier->diag, diag_last_error(&replicaset.applier.diag)); } /* Stop the applier fiber. */ diff --git a/src/box/error.cc b/src/box/error.cc index 47dce3305..7dfe1b3ee 100644 --- a/src/box/error.cc +++ b/src/box/error.cc @@ -82,7 +82,7 @@ box_error_set(const char *file, unsigned line, uint32_t code, error_vformat_msg(e, fmt, ap); va_end(ap); } - diag_add_error(&fiber()->diag, e); + diag_set_error(&fiber()->diag, e); return -1; } diff --git a/src/box/relay.cc b/src/box/relay.cc index a19abf6a9..1f6cb28b7 100644 --- a/src/box/relay.cc +++ b/src/box/relay.cc @@ -449,7 +449,7 @@ relay_set_error(struct relay *relay, struct error *e) { /* Don't override existing error. */ if (diag_is_empty(&relay->diag)) - diag_add_error(&relay->diag, e); + diag_set_error(&relay->diag, e); } static void @@ -623,7 +623,7 @@ relay_subscribe_f(va_list ap) * Don't clear the error for status reporting. */ assert(!diag_is_empty(&relay->diag)); - diag_add_error(diag_get(), diag_last_error(&relay->diag)); + diag_set_error(diag_get(), diag_last_error(&relay->diag)); diag_log(); say_crit("exiting the relay loop"); diff --git a/src/lib/core/exception.cc b/src/lib/core/exception.cc index a6999af43..55ee8cd40 100644 --- a/src/lib/core/exception.cc +++ b/src/lib/core/exception.cc @@ -99,7 +99,7 @@ Exception::operator new(size_t size) void *buf = malloc(size); if (buf != NULL) return buf; - diag_add_error(diag_get(), &out_of_memory); + diag_set_error(diag_get(), &out_of_memory); throw &out_of_memory; } -- 2.22.1