From: Vsevolod Stakhov Date: Thu, 13 Oct 2022 22:15:15 +0000 (+0100) Subject: [Fix] Another try to fix close method in lua_tcp X-Git-Tag: 3.4~55 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=5209f8541be49ddc3ca736cb336a5117bb32a971;p=thirdparty%2Frspamd.git [Fix] Another try to fix close method in lua_tcp --- diff --git a/src/lua/lua_tcp.c b/src/lua/lua_tcp.c index 643978a49f..82d6af0ee3 100644 --- a/src/lua/lua_tcp.c +++ b/src/lua/lua_tcp.c @@ -1165,6 +1165,12 @@ lua_tcp_handler (int fd, short what, gpointer ud) else { g_assert_not_reached (); } + + if ((cbd->flags & (LUA_TCP_FLAG_FINISHED|LUA_TCP_FLAG_CONNECTED)) == + (LUA_TCP_FLAG_FINISHED|LUA_TCP_FLAG_CONNECTED)) { + /* A callback has called `close` method, so we need to release a refcount */ + TCP_RELEASE (cbd); + } } else { lua_tcp_push_error (cbd, TRUE, "IO timeout");