moonbridge

changeset 147:43387f11b096

Do not pass moonbridge_io.block when invoking callback passed to _call I/O methods but only include it for _yield I/O methods
author jbe
date Thu May 07 22:16:15 2015 +0200 (2015-05-07)
parents 6dfe5b424b18
children c51c38d991df
files Makefile moonbridge_io.c
line diff
     1.1 --- a/Makefile	Thu May 07 21:32:58 2015 +0200
     1.2 +++ b/Makefile	Thu May 07 22:16:15 2015 +0200
     1.3 @@ -68,5 +68,5 @@
     1.4  	ld -shared -o moonbridge_websocket.so -lmd moonbridge_websocket.o
     1.5  
     1.6  clean::
     1.7 -	rm -f moonbridge moonbridge_io.o moonbridge_websocket.so
     1.8 +	rm -f moonbridge moonbridge_io.o moonbridge_io.so moonbridge_websocket.o moonbridge_websocket.so
     1.9  
     2.1 --- a/moonbridge_io.c	Thu May 07 21:32:58 2015 +0200
     2.2 +++ b/moonbridge_io.c	Thu May 07 22:16:15 2015 +0200
     2.3 @@ -73,8 +73,10 @@
     2.4    int nonblocking;
     2.5  } moonbr_io_listener_t;
     2.6  
     2.7 -static int moonbr_io_yield(lua_State *L) {
     2.8 -  return lua_yield(L, 0);
     2.9 +static int moonbr_io_yield_block(lua_State *L) {
    2.10 +  lua_pushlightuserdata(L, &moonbr_io_block_udata);
    2.11 +  lua_insert(L, 1);
    2.12 +  return lua_yield(L, lua_gettop(L));
    2.13  }
    2.14  
    2.15  #if LUA_VERSION_NUM >= 503
    2.16 @@ -91,7 +93,7 @@
    2.17      lua_pushcfunction(L, callfunc); \
    2.18      lua_insert(L, 1); \
    2.19      args = lua_gettop(L); \
    2.20 -    lua_pushcfunction(L, moonbr_io_yield); \
    2.21 +    lua_pushcfunction(L, moonbr_io_yield_block); \
    2.22      lua_insert(L, 3); \
    2.23      lua_callk(L, args, LUA_MULTRET, 0, moonbr_io_cont_returnall); \
    2.24      return lua_gettop(L); \
    2.25 @@ -334,10 +336,9 @@
    2.26        lua_replace(L, 3);
    2.27      }
    2.28      lua_pushvalue(L, 2);
    2.29 -    lua_pushlightuserdata(L, &moonbr_io_block_udata);
    2.30      lua_pushvalue(L, 1);
    2.31      lua_pushliteral(L, "r");
    2.32 -    lua_callk(L, 3, 0, ctx, moonbr_io_read_cont);
    2.33 +    lua_callk(L, 2, 0, ctx, moonbr_io_read_cont);
    2.34    }
    2.35    if (ctx == 1) {
    2.36      lua_pushvalue(L, 5);
    2.37 @@ -399,10 +400,9 @@
    2.38        lua_replace(L, 3);
    2.39      }
    2.40      lua_pushvalue(L, 2);
    2.41 -    lua_pushlightuserdata(L, &moonbr_io_block_udata);
    2.42      lua_pushvalue(L, 1);
    2.43      lua_pushliteral(L, "r");
    2.44 -    lua_callk(L, 3, 0, ctx, moonbr_io_drain_cont);
    2.45 +    lua_callk(L, 2, 0, ctx, moonbr_io_drain_cont);
    2.46    }
    2.47    lua_pushinteger(L, totallen);
    2.48    lua_pushvalue(L, -2);
    2.49 @@ -580,10 +580,9 @@
    2.50      }
    2.51      lua_pop(L, 2);
    2.52      lua_pushvalue(L, 2);
    2.53 -    lua_pushlightuserdata(L, &moonbr_io_block_udata);
    2.54      lua_pushvalue(L, 1);
    2.55      lua_pushliteral(L, "w");
    2.56 -    lua_callk(L, 3, 0, 0, moonbr_io_write_cont);
    2.57 +    lua_callk(L, 2, 0, 0, moonbr_io_write_cont);
    2.58    }
    2.59  }
    2.60  

Impressum / About Us