From 4e43741943780b6fc21d2e93d1e99812778cad24 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Mon, 30 Mar 2009 15:39:20 -0300 Subject: [PATCH] in 'lua_call', avoid preparing a continuation when thread cannot yield. --- lapi.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/lapi.c b/lapi.c index eb4fe4f3..9b1f2462 100644 --- a/lapi.c +++ b/lapi.c @@ -1,5 +1,5 @@ /* -** $Id: lapi.c,v 2.71 2009/03/10 17:14:37 roberto Exp roberto $ +** $Id: lapi.c,v 2.72 2009/03/23 14:26:12 roberto Exp roberto $ ** Lua API ** See Copyright Notice in lua.h */ @@ -779,14 +779,14 @@ LUA_API void lua_callk (lua_State *L, int nargs, int nresults, int ctx, api_checknelems(L, nargs+1); checkresults(L, nargs, nresults); func = L->top - (nargs+1); - if (k != NULL) { - L->ci->u.c.k = k; - L->ci->u.c.ctx = ctx; - L->ci->callstatus |= CIST_CTX; - luaD_call(L, func, nresults, 1); + if (k != NULL && L->nny == 0) { /* need to prepare continuation? */ + L->ci->u.c.k = k; /* save continuation */ + L->ci->u.c.ctx = ctx; /* save context */ + L->ci->callstatus |= CIST_CTX; /* mark that call has context */ + luaD_call(L, func, nresults, 1); /* do the call */ } - else - luaD_call(L, func, nresults, 0); + else /* no continuation or no yieldable */ + luaD_call(L, func, nresults, 0); /* just do the call */ adjustresults(L, nresults); lua_unlock(L); }