# HG changeset patch # User jbe # Date 1431030141 -7200 # Node ID c51c38d991df8a35ed447722167b89bb8bd8ba55 # Parent 43387f11b09689efb8b3efc72e5909e17ff6ba3f Reverted previous commit (but changes to Makefile) diff -r 43387f11b096 -r c51c38d991df moonbridge_io.c --- a/moonbridge_io.c Thu May 07 22:16:15 2015 +0200 +++ b/moonbridge_io.c Thu May 07 22:22:21 2015 +0200 @@ -73,10 +73,8 @@ int nonblocking; } moonbr_io_listener_t; -static int moonbr_io_yield_block(lua_State *L) { - lua_pushlightuserdata(L, &moonbr_io_block_udata); - lua_insert(L, 1); - return lua_yield(L, lua_gettop(L)); +static int moonbr_io_yield(lua_State *L) { + return lua_yield(L, 0); } #if LUA_VERSION_NUM >= 503 @@ -93,7 +91,7 @@ lua_pushcfunction(L, callfunc); \ lua_insert(L, 1); \ args = lua_gettop(L); \ - lua_pushcfunction(L, moonbr_io_yield_block); \ + lua_pushcfunction(L, moonbr_io_yield); \ lua_insert(L, 3); \ lua_callk(L, args, LUA_MULTRET, 0, moonbr_io_cont_returnall); \ return lua_gettop(L); \ @@ -336,9 +334,10 @@ lua_replace(L, 3); } lua_pushvalue(L, 2); + lua_pushlightuserdata(L, &moonbr_io_block_udata); lua_pushvalue(L, 1); lua_pushliteral(L, "r"); - lua_callk(L, 2, 0, ctx, moonbr_io_read_cont); + lua_callk(L, 3, 0, ctx, moonbr_io_read_cont); } if (ctx == 1) { lua_pushvalue(L, 5); @@ -400,9 +399,10 @@ lua_replace(L, 3); } lua_pushvalue(L, 2); + lua_pushlightuserdata(L, &moonbr_io_block_udata); lua_pushvalue(L, 1); lua_pushliteral(L, "r"); - lua_callk(L, 2, 0, ctx, moonbr_io_drain_cont); + lua_callk(L, 3, 0, ctx, moonbr_io_drain_cont); } lua_pushinteger(L, totallen); lua_pushvalue(L, -2); @@ -580,9 +580,10 @@ } lua_pop(L, 2); lua_pushvalue(L, 2); + lua_pushlightuserdata(L, &moonbr_io_block_udata); lua_pushvalue(L, 1); lua_pushliteral(L, "w"); - lua_callk(L, 2, 0, 0, moonbr_io_write_cont); + lua_callk(L, 3, 0, 0, moonbr_io_write_cont); } }