]> source.dussan.org Git - rspamd.git/commitdiff
[Fix] Lua_tcp: Another try to fix closing logic
authorVsevolod Stakhov <vsevolod@rspamd.com>
Sat, 24 Sep 2022 12:03:11 +0000 (13:03 +0100)
committerVsevolod Stakhov <vsevolod@rspamd.com>
Sat, 24 Sep 2022 12:03:11 +0000 (13:03 +0100)
src/lua/lua_tcp.c

index 78085ecc66be8825a96950dad58fbe114c2bf81d..952ea06ba2db22607600c82e94927bedc4d262bf 100644 (file)
@@ -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;
 }