diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2020-07-06 13:54:01 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2020-07-06 13:54:01 -0300 |
commit | d39ea8b3ce684728c1ad5005192766d39d2e8baa (patch) | |
tree | a6366af9c0fb14af5b244b609cbc3da2b652b798 /ltests.c | |
parent | 6298903e35217ab69c279056f925fb72900ce0b7 (diff) | |
download | lua-d39ea8b3ce684728c1ad5005192766d39d2e8baa.tar.gz lua-d39ea8b3ce684728c1ad5005192766d39d2e8baa.tar.bz2 lua-d39ea8b3ce684728c1ad5005192766d39d2e8baa.zip |
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'.
Diffstat (limited to 'ltests.c')
-rw-r--r-- | ltests.c | 7 |
1 files changed, 5 insertions, 2 deletions
@@ -145,7 +145,6 @@ static void warnf (void *ud, const char *msg, int tocont) { | |||
145 | lua_pushstring(L, buff); | 145 | lua_pushstring(L, buff); |
146 | lua_setglobal(L, "_WARN"); /* assign message to global '_WARN' */ | 146 | lua_setglobal(L, "_WARN"); /* assign message to global '_WARN' */ |
147 | lua_lock(L); | 147 | lua_lock(L); |
148 | buff[0] = '\0'; /* prepare buffer for next warning */ | ||
149 | break; | 148 | break; |
150 | } | 149 | } |
151 | } | 150 | } |
@@ -749,11 +748,12 @@ static int listlocals (lua_State *L) { | |||
749 | static void printstack (lua_State *L) { | 748 | static void printstack (lua_State *L) { |
750 | int i; | 749 | int i; |
751 | int n = lua_gettop(L); | 750 | int n = lua_gettop(L); |
751 | printf("stack: >>\n"); | ||
752 | for (i = 1; i <= n; i++) { | 752 | for (i = 1; i <= n; i++) { |
753 | printf("%3d: %s\n", i, luaL_tolstring(L, i, NULL)); | 753 | printf("%3d: %s\n", i, luaL_tolstring(L, i, NULL)); |
754 | lua_pop(L, 1); | 754 | lua_pop(L, 1); |
755 | } | 755 | } |
756 | printf("\n"); | 756 | printf("<<\n"); |
757 | } | 757 | } |
758 | 758 | ||
759 | 759 | ||
@@ -1678,6 +1678,9 @@ static struct X { int x; } x; | |||
1678 | if (n == 0) n = lua_gettop(fs); | 1678 | if (n == 0) n = lua_gettop(fs); |
1679 | lua_xmove(fs, ts, n); | 1679 | lua_xmove(fs, ts, n); |
1680 | } | 1680 | } |
1681 | else if EQ("isyieldable") { | ||
1682 | lua_pushboolean(L1, lua_isyieldable(lua_tothread(L1, getindex))); | ||
1683 | } | ||
1681 | else if EQ("yield") { | 1684 | else if EQ("yield") { |
1682 | return lua_yield(L1, getnum); | 1685 | return lua_yield(L1, getnum); |
1683 | } | 1686 | } |