[Tarantool-patches] [PATCH] console: check on_shutdown() before exit

Cyrill Gorcunov gorcunov at gmail.com
Sun Apr 12 13:37:21 MSK 2020


On Sun, Apr 12, 2020 at 02:10:34AM +0300, Roman Khabibov wrote:
> Add check that on_shutdown() triggers were called before exit,
> because in case of EOF or Ctrl+D (no signals) they were ignored.
> 
> Closes #4703

Ok, I don't see any obvious problems with the patch. Only a nit
due to coding style below.
...
> diff --git a/test/box/on_shutdown.test.lua b/test/box/on_shutdown.test.lua
> index 2a9143404..795887202 100644
> --- a/test/box/on_shutdown.test.lua
> +++ b/test/box/on_shutdown.test.lua
> @@ -65,3 +65,20 @@ test_run:grep_log('test', 'signal', nil, {noreset=true})
...
> +on_shutdown_cmd = "box.ctl.on_shutdown(function() local fio = require('fio') "..
> +    "fio.open('"..file_name.."', {'O_CREAT', 'O_TRUNC', 'O_WRONLY'}, 777):clo"..
> +    "se() end)";

This is ugly as hell. Can we please do not split "close". Something like

on_shutdown_cmd = "box.ctl.on_shutdown(function() local fio = require('fio') "..
	"fio.open('"..file_name.."', "..
	"{'O_CREAT', 'O_TRUNC', 'O_WRONLY'}, 777):close() end)";

Or somehow more readable? Maybe like

on_shutdown_cmd = "box.ctl.on_shutdown(function() local fio = require('fio') "..
	"local flags = {'O_CREAT', 'O_TRUNC', 'O_WRONLY'}" ..
	"local f = fio.open(mode, 777)" ..
	"f:close()"

(I'm sure I've done some typos here but you get the idea)


More information about the Tarantool-patches mailing list