From: Vladimir Davydov <vdavydov.dev@gmail.com> To: Serge Petrenko <sergepetrenko@tarantool.org> Cc: kostja@tarantool.org, tarantool-patches@freelists.org Subject: Re: [tarantool-patches] [PATCH v3 1/3] box: get rid of atexit() for calling cleanup routine Date: Thu, 27 Dec 2018 15:43:55 +0300 [thread overview] Message-ID: <20181227124355.hmoioqgodmkcjclu@esperanza> (raw) In-Reply-To: <98b93e4fd2d6d6affb4dc191ad5d4e8432ffefaa.1544533138.git.sergepetrenko@tarantool.org> 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? > @@ -119,11 +120,33 @@ sig_checkpoint(ev_loop * /* loop */, struct ev_signal * /* w */, > fiber_wakeup(f); > } > > +static int > +on_exit_f(va_list ap) > +{ > + (void) ap; > + /* Terminate the main event loop. */ > + ev_break(loop(), EVBREAK_ALL); > + return 0; > +} > + > +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. > +} > + > static void > signal_cb(ev_loop *loop, struct ev_signal *w, int revents) > { > (void) w; > (void) revents; > + (void) loop; > > /** > * If running in daemon mode, complain about possibly > @@ -135,8 +158,8 @@ signal_cb(ev_loop *loop, struct ev_signal *w, int revents) > if (pid_file) > say_crit("got signal %d - %s", w->signum, strsignal(w->signum)); > start_loop = false; > - /* Terminate the main event loop */ > - ev_break(loop, EVBREAK_ALL); > + > + tarantool_exit(); > }
next prev parent reply other threads:[~2018-12-27 12:43 UTC|newest] Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top 2018-12-11 13:24 [tarantool-patches] [PATCH v3 0/3] box: implement on_shutdown triggers Serge Petrenko 2018-12-11 13:24 ` [tarantool-patches] [PATCH v3 1/3] box: get rid of atexit() for calling cleanup routine Serge Petrenko 2018-12-27 12:43 ` Vladimir Davydov [this message] 2018-12-27 12:50 ` Konstantin Osipov 2018-12-27 12:56 ` Vladimir Davydov 2018-12-28 7:43 ` [tarantool-patches] " Konstantin Osipov 2018-12-28 7:58 ` Vladimir Davydov 2018-12-29 13:54 ` Serge Petrenko 2018-12-11 13:24 ` [tarantool-patches] [PATCH v3 2/3] box: implement on_shutdown triggers Serge Petrenko 2018-12-27 13:11 ` Vladimir Davydov 2018-12-11 13:24 ` [tarantool-patches] [PATCH v3 3/3] box: introduce on_shutdown triggers to lua Serge Petrenko 2018-12-27 13:14 ` Vladimir Davydov
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=20181227124355.hmoioqgodmkcjclu@esperanza \ --to=vdavydov.dev@gmail.com \ --cc=kostja@tarantool.org \ --cc=sergepetrenko@tarantool.org \ --cc=tarantool-patches@freelists.org \ --subject='Re: [tarantool-patches] [PATCH v3 1/3] box: get rid of atexit() for calling cleanup routine' \ /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