Skip to content

Commit

Permalink
fix(socket): ev_io and ev_timer should be stoped in close.
Browse files Browse the repository at this point in the history
Signed-off-by: Jianhui Zhao <zhaojh329@gmail.com>
  • Loading branch information
zhaojh329 committed Apr 11, 2024
1 parent 45d492f commit dd5db47
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions socket.c
Original file line number Diff line number Diff line change
Expand Up @@ -738,6 +738,7 @@ static int lua_closed(lua_State *L)
static int lua_sock_close(lua_State *L)
{
struct eco_socket *sock = luaL_checkudata(L, 1, ECO_SOCKET_MT);
struct ev_loop *loop = sock->eco->loop;

if (sock->fd < 0)
return 0;
Expand All @@ -750,6 +751,9 @@ static int lua_sock_close(lua_State *L)
unlink(un.sun_path);
}

ev_timer_stop(loop, &sock->tmr);
ev_io_stop(loop, &sock->io);

close(sock->fd);

sock->fd = -1;
Expand Down

0 comments on commit dd5db47

Please sign in to comment.