From: Serge Petrenko <sergepetrenko@tarantool.org> To: vdavydov.dev@gmail.com, kostja@tarantool.org Cc: tarantool-patches@freelists.org, Serge Petrenko <sergepetrenko@tarantool.org> Subject: [PATCH v5 0/3] box: implement on_shutdown triggers Date: Fri, 25 Jan 2019 18:41:31 +0300 [thread overview] Message-ID: <cover.1548430046.git.sergepetrenko@tarantool.org> (raw) This patchset adds on_shutdown triggers which can be registered from lua via box.ctl.on_shutdown() and are run on tarantool shutdown. Issue: https://github.com/tarantool/tarantool/issues/1607 Branch: https://github.com/tarantool/tarantool/tree/sp/gh-1607-on-exit-triggers Changes in v2: - added 3rd patch which passes signals to triggers. - run on_shutdown triggers even if box is not configured. - add a documentation request to the 3rd patch. Changes in v3: - remove the patch which passes signals to the trigger, since the triggers are not run on fatal signals at all, and doing this for SIGTERM or SIGINT is not of much use. - Add a new patch which moves tarantool_free() from atexit() to end of main(). Only close the journal and restore terminal state (if needed) in atexit handlers. Also in signal handler create a new fiber which breaks the event loop. on_shutdown triggers will be run from this fiber before ev loop break. - add tests that on_shutdown triggers can yield to the third patch. Changes in v4: - squashed 2nd and 3rd patches - review fixes as per review by @locker - made 1st and 2nd patches independent. 1st patch may be dropped if we decide not to implement it. Changes in v5: - patched os.exit() to call on_shutdown triggers - some minor fixes as per review by @locker - the patch which removes atexit() registration for cleanup routines is moved last. It is now completely trivial thanks to the os.exit() patch. The first patch implements on_shutdown triggers. The triggers are run from a fiber before ev_loop break, and the last executed trigger breaks ev_loop. The triggers are exposed to lua via box.ctl.on_shutdown(). The second patch alters os.exit() to call on_shutdown triggers. Now behaviour after os.exit() is identical to the behaviour after receiving SIGINT. (Except that exit code is changed). The third patch removes cleanup routines from atexit to the end of main(). This can be done thanks to the first two patches, which ensure that during normal termination control always reaches end of main(). Serge Petrenko (3): box: implement on_shutdown triggers lua: patch os.exit() to execute on_shutdown triggers. box: get rid of atexit() for calling cleanup routines extra/exports | 1 + src/box/box.cc | 2 ++ src/box/box.h | 3 ++ src/box/lua/ctl.c | 8 +++++ src/lua/init.lua | 7 ++++ src/lua/trigger.c | 5 ++- src/main.cc | 60 +++++++++++++++++++++++++++++++---- src/main.h | 3 ++ test/box/misc.result | 72 ++++++++++++++++++++++++++++++++++++++++++ test/box/misc.test.lua | 32 +++++++++++++++++++ 10 files changed, 185 insertions(+), 8 deletions(-) -- 2.17.2 (Apple Git-113)
next reply other threads:[~2019-01-25 15:41 UTC|newest] Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top 2019-01-25 15:41 Serge Petrenko [this message] 2019-01-25 15:41 ` [PATCH v5 1/3] " Serge Petrenko 2019-01-28 8:43 ` Vladimir Davydov 2019-01-29 14:47 ` Serge Petrenko 2019-01-25 15:41 ` [PATCH v5 2/3] lua: patch os.exit() to execute " Serge Petrenko 2019-01-28 8:45 ` Vladimir Davydov 2019-01-29 14:49 ` [tarantool-patches] " Serge Petrenko 2019-01-25 15:41 ` [PATCH v5 3/3] box: get rid of atexit() for calling cleanup routines Serge Petrenko 2019-01-30 10:52 ` [PATCH v5 0/3] box: implement on_shutdown triggers 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=cover.1548430046.git.sergepetrenko@tarantool.org \ --to=sergepetrenko@tarantool.org \ --cc=kostja@tarantool.org \ --cc=tarantool-patches@freelists.org \ --cc=vdavydov.dev@gmail.com \ --subject='Re: [PATCH v5 0/3] 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