moonbridge
diff moonbridge_io.c @ 100:df1ab25c6513
Bugfix in C function moonbr_io_closehandle
author | jbe |
---|---|
date | Wed Apr 08 05:11:58 2015 +0200 (2015-04-08) |
parents | c9ffbdac1337 |
children | 51ff6ad11677 |
line diff
1.1 --- a/moonbridge_io.c Wed Apr 08 04:22:03 2015 +0200 1.2 +++ b/moonbridge_io.c Wed Apr 08 05:11:58 2015 +0200 1.3 @@ -424,14 +424,13 @@ 1.4 return 0; 1.5 } 1.6 1.7 -void moonbr_io_closehandle(lua_State *L, int idx, int timeout) { 1.8 +void moonbr_io_closehandle(lua_State *L, int idx, int reset) { 1.9 moonbr_io_handle_t *handle; 1.10 handle = luaL_checkudata(L, idx, MOONBR_IO_HANDLE_MT_REGKEY); 1.11 - if (handle->fd >= 0) { 1.12 - lua_pushcfunction(L, moonbr_io_close); 1.13 - lua_pushvalue(L, idx); 1.14 - lua_pushinteger(L, timeout); 1.15 - lua_call(L, 2, 0); 1.16 + if (!handle->closed) { 1.17 + lua_pushcfunction(L, reset ? moonbr_io_reset : moonbr_io_close); 1.18 + lua_pushvalue(L, idx < 0 ? idx-1 : idx); 1.19 + lua_call(L, 1, 0); 1.20 } 1.21 } 1.22