diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2020-12-18 11:22:42 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2020-12-18 11:22:42 -0300 |
commit | 409256b7849ec5ab3296cb0ab9eba3d65955d5ea (patch) | |
tree | 13d6327093e900cab0b23c4d09f344a281630c73 /lstate.c | |
parent | b17178b27a55bd5eeb51538bec935972fd58f1ea (diff) | |
download | lua-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.c | 8 |
1 files changed, 5 insertions, 3 deletions
@@ -323,14 +323,16 @@ void luaE_freethread (lua_State *L, lua_State *L1) { | |||
323 | 323 | ||
324 | int lua_resetthread (lua_State *L) { | 324 | int 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; |