From: Konstantin Osipov <kostja@tarantool.org>
To: tarantool-patches@freelists.org
Subject: [tarantool-patches] [PATCH] box: implement on_shutdown triggers
Date: Thu, 1 Nov 2018 15:53:49 +0300 [thread overview]
Message-ID: <20181101125349.GA28060@chai> (raw)
https://github.com/tarantool/tarantool/issues/3159
https://github.com/tarantool/tarantool/tree/kostja/gh-3159-on-ctl
---
src/box/box.cc | 3 +++
src/box/box.h | 3 +++
src/main.cc | 7 +++++--
3 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/src/box/box.cc b/src/box/box.cc
index c4b4fb499..aefc02e81 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);
@@ -1653,6 +1655,7 @@ box_free(void)
* initialized
*/
if (is_box_configured) {
+ trigger_run(&on_shutdown, NULL);
#if 0
session_free();
user_cache_free();
diff --git a/src/box/box.h b/src/box/box.h
index 9f5b3acbd..3db82d2bf 100644
--- a/src/box/box.h
+++ b/src/box/box.h
@@ -63,6 +63,9 @@ struct vclock;
*/
extern const struct vclock *box_vclock;
+/** Invoked on box shutdown. */
+extern struct rlist on_shutdown;
+
/*
* Initialize box library
* @throws C++ exception
diff --git a/src/main.cc b/src/main.cc
index a36a2b0d0..dca7f1269 100644
--- a/src/main.cc
+++ b/src/main.cc
@@ -543,12 +543,15 @@ tarantool_free(void)
*/
if (!cord_is_main())
return;
+ /*
+ * Free the box first as it uses core infrastructure such
+ * as cbus, trigger and diag during shutdown.
+ */
+ box_free();
/* Shutdown worker pool. Waits until threads terminate. */
coio_shutdown();
- box_free();
-
title_free(main_argc, main_argv);
/* unlink pidfile. */
--
2.17.1
--
Konstantin Osipov, Moscow, Russia, +7 903 626 22 32
http://tarantool.io - www.twitter.com/kostja_osipov
reply other threads:[~2018-11-01 12:53 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20181101125349.GA28060@chai \
--to=kostja@tarantool.org \
--cc=tarantool-patches@freelists.org \
--subject='Re: [tarantool-patches] [PATCH] 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