Correctly continue receive_buf on immediate error/success

This commit is contained in:
dmiller 2026-05-05 20:58:56 +00:00
parent 9458beda4c
commit 3a528e1d1d

View file

@ -792,12 +792,12 @@ static int receive_buf (lua_State *L, int status, lua_KContext ctx)
else
{
lua_pop(L, 2); /* pop 2 results */
int oldtop = lua_gettop(L);
nu->action = "RECEIVE BUF";
nsock_read(nsp, nu->nsiod, receive_callback, nu->timeout, nu);
if (nu->action == NU_ACTION_IMMEDIATE) {
// Immediate return
return lua_gettop(L) - oldtop;
// Immediate return. We can't yield since the callback already ran, so we
// call ourselves as a continuation just like Lua would have.
return receive_buf(L, LUA_YIELD, 0);
}
return yield(L, nu, "RECEIVE BUF", FROM, 0, receive_buf);
}