[PATCH v5 3/3] box: get rid of atexit() for calling cleanup routines

Serge Petrenko sergepetrenko at tarantool.org
Fri Jan 25 18:41:34 MSK 2019


Move a call to tarantool_free() to the end of main().
We needn't call atexit() at all anymore, since we've implemented
on_shutdown triggers and patched os.exit() so that when exiting not
due to a fatal signal (when no cleanup routines are called anyway)
control always reaches a call to tarantool_free().
---
 src/main.cc | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/src/main.cc b/src/main.cc
index a3d1a6f22..3fc2dd310 100644
--- a/src/main.cc
+++ b/src/main.cc
@@ -800,9 +800,6 @@ main(int argc, char **argv)
 		trigger_create(&shutdown_trig, break_loop, NULL, NULL);
 		trigger_add(&box_on_shutdown, &shutdown_trig);
 
-		/* main core cleanup routine */
-		atexit(tarantool_free);
-
 		if (!loop())
 			panic("%s", "can't init event loop");
 
@@ -841,5 +838,6 @@ main(int argc, char **argv)
 	if (start_loop)
 		say_crit("exiting the event loop");
 	/* freeing resources */
+	tarantool_free();
 	return exit_code;
 }
-- 
2.17.2 (Apple Git-113)




More information about the Tarantool-patches mailing list