[tarantool-patches] [PATCH v3 1/3] box: get rid of atexit() for calling cleanup routine

Konstantin Osipov kostja at tarantool.org
Thu Dec 27 15:50:58 MSK 2018


* Vladimir Davydov <vdavydov.dev at gmail.com> [18/12/27 15:45]:
> On Tue, Dec 11, 2018 at 04:24:38PM +0300, Serge Petrenko wrote:
> > Move a call to tarantool_free() to the end of main().
> > Also instead of breaking the event loop directly when processing a
> > signal start a fiber which can do some work before event loop break and
> > then break the event loop (this will be helpful when on_shutdown
> > triggers are implemented to run them while ev loop active).
> > Only wal_thread_stop() is left in atexit() to make sure we close the
> > journal in case the user exits by typing os.exit() to the console.
> 
> I don't understand why you need to do it in the scope of the issue
> you're intending to fix. You can start a fiber from SITERM/SIGINT signal
> handler and run on_shutdown triggers from it without atexit rework,
> right?

I asked Sergey to refactor our atexit machinery. I want atexit
handlers to be able to run the event loop, all such handlers, not
just the exit trigger.

> > +void
> > +tarantool_exit(void)
> > +{
> > +	struct fiber *f = fiber_new("on_shutdown", on_exit_f);
> > +	if (f == NULL) {
> > +		say_warn("failed to allocate a fiber to run shutdown routines.");
> > +		ev_break(loop(), EVBREAK_ALL);
> > +		return;
> > +	}
> > +	fiber_wakeup(f);
> 
> This should be done by the patch that introduces on_shutdown triggers,
> otherwise it's unclear why you need a fiber here.

I'd prefer this fiber to be preallocated or reuse 'sched' fiber
for it.

-- 
Konstantin Osipov, Moscow, Russia, +7 903 626 22 32
http://tarantool.io - www.twitter.com/kostja_osipov



More information about the Tarantool-patches mailing list