moonbridge

changeset 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 baa30bfec659
files moonbridge.c moonbridge_io.c moonbridge_io.h
line diff
     1.1 --- a/moonbridge.c	Wed Apr 08 04:22:03 2015 +0200
     1.2 +++ b/moonbridge.c	Wed Apr 08 05:11:58 2015 +0200
     1.3 @@ -897,7 +897,7 @@
     1.4        fprintf(stderr, "Error in \"connect\" function: %s\n", lua_tostring(L, -1));
     1.5        exit(1);
     1.6      }
     1.7 -    if (fd) moonbr_io_closehandle(L, -2, -1);  /* attemt clean close */
     1.8 +    if (fd) moonbr_io_closehandle(L, -2, 0);  /* attemt clean close */
     1.9      if (lua_type(L, -1) != LUA_TBOOLEAN || !lua_toboolean(L, -1)) break;
    1.10  #ifdef MOONBR_LUA_PANIC_BUG_WORKAROUND
    1.11      lua_settop(L, 2);
     2.1 --- a/moonbridge_io.c	Wed Apr 08 04:22:03 2015 +0200
     2.2 +++ b/moonbridge_io.c	Wed Apr 08 05:11:58 2015 +0200
     2.3 @@ -424,14 +424,13 @@
     2.4    return 0;
     2.5  }
     2.6  
     2.7 -void moonbr_io_closehandle(lua_State *L, int idx, int timeout) {
     2.8 +void moonbr_io_closehandle(lua_State *L, int idx, int reset) {
     2.9    moonbr_io_handle_t *handle;
    2.10    handle = luaL_checkudata(L, idx, MOONBR_IO_HANDLE_MT_REGKEY);
    2.11 -  if (handle->fd >= 0) {
    2.12 -    lua_pushcfunction(L, moonbr_io_close);
    2.13 -    lua_pushvalue(L, idx);
    2.14 -    lua_pushinteger(L, timeout);
    2.15 -    lua_call(L, 2, 0);
    2.16 +  if (!handle->closed) {
    2.17 +    lua_pushcfunction(L, reset ? moonbr_io_reset : moonbr_io_close);
    2.18 +    lua_pushvalue(L, idx < 0 ? idx-1 : idx);
    2.19 +    lua_call(L, 1, 0);
    2.20    }
    2.21  }
    2.22  
     3.1 --- a/moonbridge_io.h	Wed Apr 08 04:22:03 2015 +0200
     3.2 +++ b/moonbridge_io.h	Wed Apr 08 05:11:58 2015 +0200
     3.3 @@ -1,6 +1,6 @@
     3.4  
     3.5  void moonbr_io_pushhandle(lua_State *L, int fd, int useshutdown);
     3.6 -void moonbr_io_closehandle(lua_State *L, int idx, int timeout);
     3.7 +void moonbr_io_closehandle(lua_State *L, int idx, int reset);
     3.8  int moonbr_io_tcpconnect(lua_State *L);
     3.9  int moonbr_io_tcpconnect_nb(lua_State *L);
    3.10  int luaopen_moonbridge_io(lua_State *L);

Impressum / About Us