aboutsummaryrefslogtreecommitdiff
path: root/lstate.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2020-12-18 11:22:42 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2020-12-18 11:22:42 -0300
commit409256b7849ec5ab3296cb0ab9eba3d65955d5ea (patch)
tree13d6327093e900cab0b23c4d09f344a281630c73 /lstate.c
parentb17178b27a55bd5eeb51538bec935972fd58f1ea (diff)
downloadlua-409256b7849ec5ab3296cb0ab9eba3d65955d5ea.tar.gz
lua-409256b7849ec5ab3296cb0ab9eba3d65955d5ea.tar.bz2
lua-409256b7849ec5ab3296cb0ab9eba3d65955d5ea.zip
'coroutine.close'/'lua_resetthread' report original errors
Besides errors in closing methods, 'coroutine.close' and 'lua_resetthread' also consider the original error that stopped the thread, if any.
Diffstat (limited to 'lstate.c')
-rw-r--r--lstate.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/lstate.c b/lstate.c
index 1596b51c..96187c66 100644
--- a/lstate.c
+++ b/lstate.c
@@ -323,14 +323,16 @@ void luaE_freethread (lua_State *L, lua_State *L1) {
323 323
324int lua_resetthread (lua_State *L) { 324int lua_resetthread (lua_State *L) {
325 CallInfo *ci; 325 CallInfo *ci;
326 int status; 326 int status = L->status;
327 lua_lock(L); 327 lua_lock(L);
328 L->ci = ci = &L->base_ci; /* unwind CallInfo list */ 328 L->ci = ci = &L->base_ci; /* unwind CallInfo list */
329 setnilvalue(s2v(L->stack)); /* 'function' entry for basic 'ci' */ 329 setnilvalue(s2v(L->stack)); /* 'function' entry for basic 'ci' */
330 ci->func = L->stack; 330 ci->func = L->stack;
331 ci->callstatus = CIST_C; 331 ci->callstatus = CIST_C;
332 status = luaF_close(L, L->stack, CLOSEPROTECT); 332 if (status == LUA_OK || status == LUA_YIELD)
333 if (status != CLOSEPROTECT) /* real errors? */ 333 status = CLOSEPROTECT; /* run closing methods in protected mode */
334 status = luaF_close(L, L->stack, status);
335 if (status != CLOSEPROTECT) /* errors? */
334 luaD_seterrorobj(L, status, L->stack + 1); 336 luaD_seterrorobj(L, status, L->stack + 1);
335 else { 337 else {
336 status = LUA_OK; 338 status = LUA_OK;