From d9b7d2be2d84b27faf113f180162988faa319e86 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Sat, 24 Sep 2022 13:03:11 +0100 Subject: [PATCH] [Fix] Lua_tcp: Another try to fix closing logic --- src/lua/lua_tcp.c | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/src/lua/lua_tcp.c b/src/lua/lua_tcp.c index 78085ecc6..952ea06ba 100644 --- a/src/lua/lua_tcp.c +++ b/src/lua/lua_tcp.c @@ -2096,7 +2096,30 @@ lua_tcp_close (lua_State *L) } cbd->flags |= LUA_TCP_FLAG_FINISHED; - TCP_RELEASE (cbd); + + if (cbd->ssl_conn) { + /* TODO: postpone close in case ssl is used ! */ + rspamd_ssl_connection_free (cbd->ssl_conn); + cbd->ssl_conn = NULL; + } + + if (cbd->fd != -1) { + rspamd_ev_watcher_stop (cbd->event_loop, &cbd->ev); + close (cbd->fd); + cbd->fd = -1; + } + + if (cbd->addr) { + rspamd_inet_address_free (cbd->addr); + cbd->addr = NULL; + } + + if (cbd->up) { + rspamd_upstream_unref(cbd->up); + cbd->up = NULL; + } + /* Do not release refcount as it will be handled elsewhere */ + /* TCP_RELEASE (cbd); */ return 0; } -- 2.39.5