* [PATCH] lua: fix tarantool -e "os.exit()" hang.
@ 2019-02-06 11:36 Serge Petrenko
2019-02-06 12:26 ` Vladimir Davydov
0 siblings, 1 reply; 4+ messages in thread
From: Serge Petrenko @ 2019-02-06 11:36 UTC (permalink / raw)
To: vdavydov.dev; +Cc: tarantool-patches, Serge Petrenko
After the patch which made os.exit() execute on_shutdown triggers
(see commit 6dc4c8d7b5b40d66fe0451ef4d1f4bdf4d2cf60e) we relied
on on_shutdown triggers to break the ev_loop and exit tarantool.
Hovewer, there is an auxiliary event loop which is run in
tarantool_lua_run_script() to reschedule the fiber executing chunks
of code passed by -e option and executing interactive mode.
This event loop is started only to execute interactive mode, and
doesn't exist during execution of -e chunks. Make sure we don't start
it if os.exit() was already executed in one of the chunks.
Closes #3966
---
https://github.com/tarantool/tarantool/issues/3966
https://github.com/tarantool/tarantool/tree/sp/gh-3966-os-exit-hang
src/lua/init.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/lua/init.c b/src/lua/init.c
index ca4b47f3a..d18c8af94 100644
--- a/src/lua/init.c
+++ b/src/lua/init.c
@@ -664,7 +664,8 @@ tarantool_lua_run_script(char *path, bool interactive,
* Run an auxiliary event loop to re-schedule run_script fiber.
* When this fiber finishes, it will call ev_break to stop the loop.
*/
- ev_run(loop(), 0);
+ if (start_loop)
+ ev_run(loop(), 0);
/* The fiber running the startup script has ended. */
script_fiber = NULL;
}
--
2.17.2 (Apple Git-113)
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] lua: fix tarantool -e "os.exit()" hang.
2019-02-06 11:36 [PATCH] lua: fix tarantool -e "os.exit()" hang Serge Petrenko
@ 2019-02-06 12:26 ` Vladimir Davydov
2019-02-06 13:32 ` Serge Petrenko
0 siblings, 1 reply; 4+ messages in thread
From: Vladimir Davydov @ 2019-02-06 12:26 UTC (permalink / raw)
To: Serge Petrenko; +Cc: tarantool-patches
On Wed, Feb 06, 2019 at 02:36:18PM +0300, Serge Petrenko wrote:
> After the patch which made os.exit() execute on_shutdown triggers
> (see commit 6dc4c8d7b5b40d66fe0451ef4d1f4bdf4d2cf60e) we relied
> on on_shutdown triggers to break the ev_loop and exit tarantool.
> Hovewer, there is an auxiliary event loop which is run in
> tarantool_lua_run_script() to reschedule the fiber executing chunks
> of code passed by -e option and executing interactive mode.
> This event loop is started only to execute interactive mode, and
> doesn't exist during execution of -e chunks. Make sure we don't start
> it if os.exit() was already executed in one of the chunks.
>
> Closes #3966
> ---
> https://github.com/tarantool/tarantool/issues/3966
> https://github.com/tarantool/tarantool/tree/sp/gh-3966-os-exit-hang
>
> src/lua/init.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/src/lua/init.c b/src/lua/init.c
> index ca4b47f3a..d18c8af94 100644
> --- a/src/lua/init.c
> +++ b/src/lua/init.c
> @@ -664,7 +664,8 @@ tarantool_lua_run_script(char *path, bool interactive,
> * Run an auxiliary event loop to re-schedule run_script fiber.
> * When this fiber finishes, it will call ev_break to stop the loop.
> */
> - ev_run(loop(), 0);
> + if (start_loop)
> + ev_run(loop(), 0);
> /* The fiber running the startup script has ended. */
> script_fiber = NULL;
> }
Please add a test. You might want to take a look at box-py/args.test.py
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] lua: fix tarantool -e "os.exit()" hang.
2019-02-06 12:26 ` Vladimir Davydov
@ 2019-02-06 13:32 ` Serge Petrenko
2019-02-06 14:06 ` Vladimir Davydov
0 siblings, 1 reply; 4+ messages in thread
From: Serge Petrenko @ 2019-02-06 13:32 UTC (permalink / raw)
To: Vladimir Davydov; +Cc: tarantool-patches
> 6 февр. 2019 г., в 15:26, Vladimir Davydov <vdavydov.dev@gmail.com> написал(а):
>
> On Wed, Feb 06, 2019 at 02:36:18PM +0300, Serge Petrenko wrote:
>> After the patch which made os.exit() execute on_shutdown triggers
>> (see commit 6dc4c8d7b5b40d66fe0451ef4d1f4bdf4d2cf60e) we relied
>> on on_shutdown triggers to break the ev_loop and exit tarantool.
>> Hovewer, there is an auxiliary event loop which is run in
>> tarantool_lua_run_script() to reschedule the fiber executing chunks
>> of code passed by -e option and executing interactive mode.
>> This event loop is started only to execute interactive mode, and
>> doesn't exist during execution of -e chunks. Make sure we don't start
>> it if os.exit() was already executed in one of the chunks.
>>
>> Closes #3966
>> ---
>> https://github.com/tarantool/tarantool/issues/3966
>> https://github.com/tarantool/tarantool/tree/sp/gh-3966-os-exit-hang
>>
>> src/lua/init.c | 3 ++-
>> 1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/src/lua/init.c b/src/lua/init.c
>> index ca4b47f3a..d18c8af94 100644
>> --- a/src/lua/init.c
>> +++ b/src/lua/init.c
>> @@ -664,7 +664,8 @@ tarantool_lua_run_script(char *path, bool interactive,
>> * Run an auxiliary event loop to re-schedule run_script fiber.
>> * When this fiber finishes, it will call ev_break to stop the loop.
>> */
>> - ev_run(loop(), 0);
>> + if (start_loop)
>> + ev_run(loop(), 0);
>> /* The fiber running the startup script has ended. */
>> script_fiber = NULL;
>> }
>
> Please add a test. You might want to take a look at box-py/args.test.py
Hi! Fixes are on the branch, here’s an incremental diff.
diff --git a/test/box-py/args.result b/test/box-py/args.result
index fe9ac3448..54629edea 100644
--- a/test/box-py/args.result
+++ b/test/box-py/args.result
@@ -118,6 +118,12 @@ Compiler: cc
C_FLAGS: flags
CXX_FLAGS: flags
+tarantool -e print(1) os.exit() print(2)
+1
+
+tarantool -e print(1) -e os.exit() -e print(1) -e os.exit() -e print(1)
+1
+
tarantool -e print('Hello') ${SOURCEDIR}/test/box-py/args.lua 1 2 3
Hello
arg[-1] => tarantool
diff --git a/test/box-py/args.test.py b/test/box-py/args.test.py
index ab6f8f2e7..11941304d 100644
--- a/test/box-py/args.test.py
+++ b/test/box-py/args.test.py
@@ -37,6 +37,10 @@ server.test_option(script + " 1 2 3 --help")
server.test_option(script + " --help 1 2 3")
server.test_option("-V " + script + " 1 2 3")
+server.test_option("-e \"print(1) os.exit() print(2)\"")
+
+server.test_option("-e \"print(1)\" -e \"os.exit()\" -e \"print(1)\" -e \"os.exit()\" -e \"print(1)\"")
+
server.test_option("-e \"print('Hello')\" " + script + " 1 2 3")
server.test_option("-e \"a = 10\" " + \
"-e print(a) " + \
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] lua: fix tarantool -e "os.exit()" hang.
2019-02-06 13:32 ` Serge Petrenko
@ 2019-02-06 14:06 ` Vladimir Davydov
0 siblings, 0 replies; 4+ messages in thread
From: Vladimir Davydov @ 2019-02-06 14:06 UTC (permalink / raw)
To: Serge Petrenko; +Cc: tarantool-patches
Pushed to 2.1.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2019-02-06 14:06 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-06 11:36 [PATCH] lua: fix tarantool -e "os.exit()" hang Serge Petrenko
2019-02-06 12:26 ` Vladimir Davydov
2019-02-06 13:32 ` Serge Petrenko
2019-02-06 14:06 ` Vladimir Davydov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox