aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2019-05-09 11:32:20 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2019-05-09 11:32:20 -0300
commit3f253f116e8e292977a1bded964544fb35b3d1e3 (patch)
tree14a61596df705ea11516a24ca4b2b707a89235fd
parent389116d8abcc96db3cfe2f3cc25789c089fe12d6 (diff)
downloadlua-3f253f116e8e292977a1bded964544fb35b3d1e3.tar.gz
lua-3f253f116e8e292977a1bded964544fb35b3d1e3.tar.bz2
lua-3f253f116e8e292977a1bded964544fb35b3d1e3.zip
Test for dead coroutine moved to 'lua_resume'
The test for dead coroutines done in the 'coro' library was moved to 'lua_resume', in the kernel, which already does other similar tests.
-rw-r--r--lcorolib.c4
-rw-r--r--ldo.c2
2 files changed, 2 insertions, 4 deletions
diff --git a/lcorolib.c b/lcorolib.c
index a21880d5..3fc9fb1c 100644
--- a/lcorolib.c
+++ b/lcorolib.c
@@ -35,10 +35,6 @@ static int auxresume (lua_State *L, lua_State *co, int narg) {
35 lua_pushliteral(L, "too many arguments to resume"); 35 lua_pushliteral(L, "too many arguments to resume");
36 return -1; /* error flag */ 36 return -1; /* error flag */
37 } 37 }
38 if (lua_status(co) == LUA_OK && lua_gettop(co) == 0) {
39 lua_pushliteral(L, "cannot resume dead coroutine");
40 return -1; /* error flag */
41 }
42 lua_xmove(L, co, narg); 38 lua_xmove(L, co, narg);
43 status = lua_resume(co, L, narg, &nres); 39 status = lua_resume(co, L, narg, &nres);
44 if (status == LUA_OK || status == LUA_YIELD) { 40 if (status == LUA_OK || status == LUA_YIELD) {
diff --git a/ldo.c b/ldo.c
index d474c0a0..e9a88e9e 100644
--- a/ldo.c
+++ b/ldo.c
@@ -666,6 +666,8 @@ LUA_API int lua_resume (lua_State *L, lua_State *from, int nargs,
666 if (L->status == LUA_OK) { /* may be starting a coroutine */ 666 if (L->status == LUA_OK) { /* may be starting a coroutine */
667 if (L->ci != &L->base_ci) /* not in base level? */ 667 if (L->ci != &L->base_ci) /* not in base level? */
668 return resume_error(L, "cannot resume non-suspended coroutine", nargs); 668 return resume_error(L, "cannot resume non-suspended coroutine", nargs);
669 else if (L->top - (L->ci->func + 1) == nargs) /* no function? */
670 return resume_error(L, "cannot resume dead coroutine", nargs);
669 } 671 }
670 else if (L->status != LUA_YIELD) 672 else if (L->status != LUA_YIELD)
671 return resume_error(L, "cannot resume dead coroutine", nargs); 673 return resume_error(L, "cannot resume dead coroutine", nargs);