From: Serge Petrenko <sergepetrenko@tarantool.org> To: kostja@tarantool.org, tarantool-patches@freelists.org Subject: [tarantool-patches] [PATCH v2 1/3] box: implement on_shutdown triggers Date: Mon, 26 Nov 2018 17:25:04 +0300 [thread overview] Message-ID: <144b51c2071b2f5cad0030307733debc76b02641.1543241956.git.sergepetrenko@tarantool.org> (raw) In-Reply-To: <cover.1543241956.git.sergepetrenko@tarantool.org> In-Reply-To: <cover.1543241956.git.sergepetrenko@tarantool.org> From: Konstantin Osipov <kostja@tarantool.org> @sergepetrenko: Factor out running on_shutdown triggers from box_free() into a separate function. In tarantool_free() run on_shutdown triggers before coio_shutdown(), but leave box_free() after coio_shutdown(). Otherwise tarantool hangs on shutdown occasionally. --- src/box/box.cc | 8 ++++++++ src/box/box.h | 11 +++++++++++ src/main.cc | 2 ++ 3 files changed, 21 insertions(+) diff --git a/src/box/box.cc b/src/box/box.cc index 7a1171c62..72049fabf 100644 --- a/src/box/box.cc +++ b/src/box/box.cc @@ -78,6 +78,8 @@ static char status[64] = "unknown"; /** box.stat rmean */ struct rmean *rmean_box; +struct rlist on_shutdown = RLIST_HEAD_INITIALIZER(on_shutdown); + static void title(const char *new_status) { snprintf(status, sizeof(status), "%s", new_status); @@ -1645,6 +1647,12 @@ box_set_replicaset_uuid(const struct tt_uuid *replicaset_uuid) diag_raise(); } +void +box_run_on_shutdown_triggers(void) +{ + trigger_run(&on_shutdown, NULL); +} + void box_free(void) { diff --git a/src/box/box.h b/src/box/box.h index 9f5b3acbd..e2c3aad9e 100644 --- a/src/box/box.h +++ b/src/box/box.h @@ -63,6 +63,11 @@ struct vclock; */ extern const struct vclock *box_vclock; +struct trigger; + +/** Invoked on box shutdown. */ +extern struct rlist on_shutdown; + /* * Initialize box library * @throws C++ exception @@ -76,6 +81,12 @@ box_init(void); void box_free(void); +/** + * Run on_shutdown triggers. + */ +void +box_run_on_shutdown_triggers(void); + /** * Load configuration for box library. * Panics on error. diff --git a/src/main.cc b/src/main.cc index a36a2b0d0..987c53834 100644 --- a/src/main.cc +++ b/src/main.cc @@ -544,6 +544,8 @@ tarantool_free(void) if (!cord_is_main()) return; + box_run_on_shutdown_triggers(); + /* Shutdown worker pool. Waits until threads terminate. */ coio_shutdown(); -- 2.17.2 (Apple Git-113)
next prev parent reply other threads:[~2018-11-26 14:25 UTC|newest] Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top 2018-11-26 14:25 [tarantool-patches] [PATCH v2 0/3] " Serge Petrenko 2018-11-26 14:25 ` Serge Petrenko [this message] 2018-11-26 14:25 ` [tarantool-patches] [PATCH v2 2/3] box: introduce on_shutdown triggers to lua Serge Petrenko 2018-11-26 14:25 ` [tarantool-patches] [PATCH v2 3/3] box: pass signal to on_shutdown triggers Serge Petrenko
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=144b51c2071b2f5cad0030307733debc76b02641.1543241956.git.sergepetrenko@tarantool.org \ --to=sergepetrenko@tarantool.org \ --cc=kostja@tarantool.org \ --cc=tarantool-patches@freelists.org \ --subject='Re: [tarantool-patches] [PATCH v2 1/3] box: implement on_shutdown triggers' \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox