<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">Hi! Thankyou for review. I addressed your comments.<br class=""><br class=""><blockquote type="cite" class="">28 янв. 2019 г., в 11:45, Vladimir Davydov <<a href="mailto:vdavydov.dev@gmail.com" class="">vdavydov.dev@gmail.com</a>> написал(а):<br class=""><br class="">On Fri, Jan 25, 2019 at 06:41:33PM +0300, Serge Petrenko wrote:<br class=""><blockquote type="cite" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; text-decoration: none;" class="">Note that the triggers will not be run if tarantool receives a fatal<br class="">signal: `SIGSEGV`, `SIGABORT` or any signal causing immediate program<br class="">termination.<br class=""><br class=""></blockquote><br class=""><blockquote type="cite" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; text-decoration: none;" class="">Closes #1607<br class=""></blockquote><br class="">Should go before the TarantoolBot request.<br class=""><br class=""></blockquote><br class="">Fixed.<br class=""><br class=""><blockquote type="cite" class=""><blockquote type="cite" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; text-decoration: none;" class="">---<br class="">extra/exports    |  1 +<br class="">src/lua/init.lua |  7 +++++++<br class="">src/<a href="http://main.cc" class="">main.cc</a>      | 10 ++++++----<br class="">src/main.h       |  3 +++<br class="">4 files changed, 17 insertions(+), 4 deletions(-)<br class=""></blockquote><br class="">A test is missing. Please add.<br class=""><br class=""></blockquote><br class="">Added a test<br class=""><br class=""><blockquote type="cite" class=""><blockquote type="cite" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><br class=""><br class=""><span class="Apple-tab-span" style="white-space:pre">      </span>is_shutting_down = true;<br class="">+<span class="Apple-tab-span" style="white-space:pre">      </span>exit_code = code;<br class=""><span class="Apple-tab-span" style="white-space:pre">      </span>fiber_wakeup(on_shutdown_fiber);<br class=""></blockquote><br class="">os.exit() should exit even if the fiber doesn't yield, but the following<br class="">code will hang, which is unexpected. Please fix.<br class=""><br class=""><span class="Apple-tab-span" style="white-space:pre">        </span>os.exit()<br class=""><span class="Apple-tab-span" style="white-space:pre">      </span>while true do end<br class=""></blockquote><br class="">Fixed<br class=""><br class="">I pushed the fixes on the branch<br class=""><a href="https://github.com/tarantool/tarantool/tree/sp/gh-1607-on-exit-triggers" class="">https://github.com/tarantool/tarantool/tree/sp/gh-1607-on-exit-triggers</a><br class="">Incremental diff is below.<br class=""><br class="">diff --git a/src/lua/init.lua b/src/lua/init.lua<br class="">index a961db328..9fd56f483 100644<br class="">--- a/src/lua/init.lua<br class="">+++ b/src/lua/init.lua<br class="">@@ -52,9 +52,14 @@ dostring = function(s, ...)<br class="">     return chunk(...)<br class=""> end<br class=""> <br class="">+local fiber = require("fiber")<br class=""> os.exit = function(code)<br class="">     code = (type(code) == 'number') and code or 0<br class="">     ffi.C.tarantool_exit(code)<br class="">+    -- Make sure we yield even if the code after<br class="">+    -- os.exit() never yields. After on_shutdown<br class="">+    -- fiber completes, we will never wake up again.<br class="">+    while true do fiber.yield() end<br class=""> end<br class=""> <br class=""> local function uptime()<br class="">diff --git a/test/box/misc.result b/test/box/misc.result<br class="">index 6912915c1..97189ecbb 100644<br class="">--- a/test/box/misc.result<br class="">+++ b/test/box/misc.result<br class="">@@ -1321,3 +1321,92 @@ box.space.shutdown:select{}<br class=""> box.space.shutdown:drop()<br class=""> ---<br class=""> ...<br class="">+-- Check that os.exit invokes triggers<br class="">+fiber = require("fiber")<br class="">+---<br class="">+...<br class="">+test_run:cmd("create server test with script='box/proxy.lua'")<br class="">+---<br class="">+- true<br class="">+...<br class="">+test_run:cmd("start server test")<br class="">+---<br class="">+- true<br class="">+...<br class="">+logfile = test_run:eval("test", "box.cfg.log")[1]<br class="">+---<br class="">+...<br class="">+test_run:cmd("stop server test")<br class="">+---<br class="">+- true<br class="">+...<br class="">+-- clean up any leftover logs<br class="">+require("fio").unlink(logfile)<br class="">+---<br class="">+- true<br class="">+...<br class="">+test_run:cmd("start server test")<br class="">+---<br class="">+- true<br class="">+...<br class="">+test_run:cmd("switch test")<br class="">+---<br class="">+- true<br class="">+...<br class="">+_ = box.ctl.on_shutdown(function() print("on_shutdown 5") end)<br class="">+---<br class="">+...<br class="">+-- Check that we don't hang infinitely after os.exit()<br class="">+-- even if the following code doesn't yield.<br class="">+fiber = require("fiber")<br class="">+---<br class="">+...<br class="">+_ = fiber.create(function() fiber.sleep(0.05) os.exit() while true do end end)<br class="">+---<br class="">+...<br class="">+test_run:cmd("switch default")<br class="">+---<br class="">+- true<br class="">+...<br class="">+fiber.sleep(0.1)<br class="">+---<br class="">+...<br class="">+-- The server should be already stopped by os.exit(),<br class="">+-- but start doesn't work without a prior call to stop.<br class="">+test_run:cmd("stop server test")<br class="">+---<br class="">+- true<br class="">+...<br class="">+test_run:cmd("start server test")<br class="">+---<br class="">+- true<br class="">+...<br class="">+test_run:cmd("switch test")<br class="">+---<br class="">+- true<br class="">+...<br class="">+test_run:grep_log('test', 'on_shutdown 5', nil, {noreset=true})<br class="">+---<br class="">+- on_shutdown 5<br class="">+...<br class="">+-- make sure we exited because of os.exit(), not a signal.<br class="">+test_run:grep_log('test', 'signal', nil, {noreset=true})<br class="">+---<br class="">+- null<br class="">+...<br class="">+test_run:cmd("switch default")<br class="">+---<br class="">+- true<br class="">+...<br class="">+test_run:cmd("stop server test")<br class="">+---<br class="">+- true<br class="">+...<br class="">+test_run:cmd("cleanup server test")<br class="">+---<br class="">+- true<br class="">+...<br class="">+test_run:cmd("delete server test")<br class="">+---<br class="">+- true<br class="">+...<br class="">diff --git a/test/box/misc.test.lua b/test/box/misc.test.lua<br class="">index f1c9d8e8c..18128b299 100644<br class="">--- a/test/box/misc.test.lua<br class="">+++ b/test/box/misc.test.lua<br class="">@@ -384,3 +384,33 @@ test_run:grep_log('default', 'on_shutdown 3', nil, {noreset=true})<br class=""> test_run:grep_log('default', 'on_shutdown 4', nil, {noreset=true})<br class=""> box.space.shutdown:select{}<br class=""> box.space.shutdown:drop()<br class="">+<br class="">+-- Check that os.exit invokes triggers<br class="">+fiber = require("fiber")<br class="">+test_run:cmd("create server test with script='box/proxy.lua'")<br class="">+test_run:cmd("start server test")<br class="">+logfile = test_run:eval("test", "box.cfg.log")[1]<br class="">+test_run:cmd("stop server test")<br class="">+-- clean up any leftover logs<br class="">+require("fio").unlink(logfile)<br class="">+test_run:cmd("start server test")<br class="">+test_run:cmd("switch test")<br class="">+_ = box.ctl.on_shutdown(function() print("on_shutdown 5") end)<br class="">+-- Check that we don't hang infinitely after os.exit()<br class="">+-- even if the following code doesn't yield.<br class="">+fiber = require("fiber")<br class="">+_ = fiber.create(function() fiber.sleep(0.05) os.exit() while true do end end)<br class="">+test_run:cmd("switch default")<br class="">+fiber.sleep(0.1)<br class="">+-- The server should be already stopped by os.exit(),<br class="">+-- but start doesn't work without a prior call to stop.<br class="">+test_run:cmd("stop server test")<br class="">+test_run:cmd("start server test")<br class="">+test_run:cmd("switch test")<br class="">+test_run:grep_log('test', 'on_shutdown 5', nil, {noreset=true})<br class="">+-- make sure we exited because of os.exit(), not a signal.<br class="">+test_run:grep_log('test', 'signal', nil, {noreset=true})<br class="">+test_run:cmd("switch default")<br class="">+test_run:cmd("stop server test")<br class="">+test_run:cmd("cleanup server test")<br class="">+test_run:cmd("delete server test")</body></html>