From d39ea8b3ce684728c1ad5005192766d39d2e8baa Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Mon, 6 Jul 2020 13:54:01 -0300 Subject: Make sure that main thread is non yieldable Main thread must be non yieldable even at "level 0" (bare API), outside the 'pcall' from 'lua.c'. --- ltests.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'ltests.c') diff --git a/ltests.c b/ltests.c index 164b5a25..0513354c 100644 --- a/ltests.c +++ b/ltests.c @@ -145,7 +145,6 @@ static void warnf (void *ud, const char *msg, int tocont) { lua_pushstring(L, buff); lua_setglobal(L, "_WARN"); /* assign message to global '_WARN' */ lua_lock(L); - buff[0] = '\0'; /* prepare buffer for next warning */ break; } } @@ -749,11 +748,12 @@ static int listlocals (lua_State *L) { static void printstack (lua_State *L) { int i; int n = lua_gettop(L); + printf("stack: >>\n"); for (i = 1; i <= n; i++) { printf("%3d: %s\n", i, luaL_tolstring(L, i, NULL)); lua_pop(L, 1); } - printf("\n"); + printf("<<\n"); } @@ -1678,6 +1678,9 @@ static struct X { int x; } x; if (n == 0) n = lua_gettop(fs); lua_xmove(fs, ts, n); } + else if EQ("isyieldable") { + lua_pushboolean(L1, lua_isyieldable(lua_tothread(L1, getindex))); + } else if EQ("yield") { return lua_yield(L1, getnum); } -- cgit v1.2.3-55-g6feb