Tarantool development patches archive
 help / color / mirror / Atom feed
* [tarantool-patches] [PATCH] box: implement on_shutdown triggers
@ 2018-11-01 12:53 Konstantin Osipov
  0 siblings, 0 replies; only message in thread
From: Konstantin Osipov @ 2018-11-01 12:53 UTC (permalink / raw)
  To: tarantool-patches

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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2018-11-01 12:53 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-11-01 12:53 [tarantool-patches] [PATCH] box: implement on_shutdown triggers Konstantin Osipov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox