Fix bug of unref resources in Lua binding; fd method delete -> cancel.
authorXiongfei Guo <xfguo@credosemi.com>
Fri, 20 Jun 2014 10:31:20 +0000 (10:31 +0000)
committerJohn Crispin <blogic@openwrt.org>
Tue, 24 Jun 2014 13:30:30 +0000 (14:30 +0100)
Signed-off-by: Xiongfei(Alex) Guo <xfguo@credosemi.com>
lua/uloop.c

index df57b8a..89ce60c 100644 (file)
@@ -80,7 +80,7 @@ static int ul_timer_free(lua_State *L)
 
        uloop_timeout_cancel(&tout->t);
        lua_getglobal(state, "__uloop_cb");
-       luaL_unref(L, -1, tout->r);
+       luaL_unref(state, -1, tout->r);
 
        return 1;
 }
@@ -177,10 +177,14 @@ static int ul_ufd_delete(lua_State *L)
        struct lua_uloop_fd *ufd = lua_touserdata(L, 1);
 
        uloop_fd_delete(&ufd->fd);
+
        lua_getglobal(state, "__uloop_cb");
-       luaL_unref(L, -1, ufd->r);
+       luaL_unref(state, -1, ufd->r);
+       lua_remove(state, -1);
+
        lua_getglobal(state, "__uloop_fds");
-       luaL_unref(L, -1, ufd->fd_r);
+       luaL_unref(state, -1, ufd->fd_r);
+       lua_remove(state, -1);
 
        return 1;
 }