From: Vsevolod Stakhov Date: Sat, 24 Sep 2022 12:03:11 +0000 (+0100) Subject: [Fix] Lua_tcp: Another try to fix closing logic X-Git-Tag: 3.3~13 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=d9b7d2be2d84b27faf113f180162988faa319e86;p=thirdparty%2Frspamd.git [Fix] Lua_tcp: Another try to fix closing logic --- diff --git a/src/lua/lua_tcp.c b/src/lua/lua_tcp.c index 78085ecc66..952ea06ba2 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; }