commit d9b7d2b: [Fix] Lua_tcp: Another try to fix closing logic

Vsevolod Stakhov vsevolod at rspamd.com
Sat Sep 24 19:07:03 UTC 2022


Author: Vsevolod Stakhov
Date: 2022-09-24 13:03:11 +0100
URL: https://github.com/rspamd/rspamd/commit/d9b7d2be2d84b27faf113f180162988faa319e86

[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;
 }


More information about the Commits mailing list