diff options
author | Vsevolod Stakhov <vsevolod@rspamd.com> | 2022-10-21 10:41:10 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@rspamd.com> | 2022-10-21 10:41:10 +0100 |
commit | 075fa9fb2dd9b8e0c2fe9758a93502c124a005e2 (patch) | |
tree | 5e7cf6c170d010925892456e8372a03b4a9f1088 /src/lua | |
parent | bd2f3f1c94449e4db55ddcfdd3c492d3edd60c19 (diff) | |
download | rspamd-075fa9fb2dd9b8e0c2fe9758a93502c124a005e2.tar.gz rspamd-075fa9fb2dd9b8e0c2fe9758a93502c124a005e2.zip |
[Fix] Lua_tcp: Sigh, another try to fix `close` invocation
Diffstat (limited to 'src/lua')
-rw-r--r-- | src/lua/lua_tcp.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/lua/lua_tcp.c b/src/lua/lua_tcp.c index 82d6af0ee..2ea3affa6 100644 --- a/src/lua/lua_tcp.c +++ b/src/lua/lua_tcp.c @@ -1044,6 +1044,11 @@ lua_tcp_process_read (struct lua_tcp_cbdata *cbd, } else { lua_tcp_push_error (cbd, TRUE, "IO read error: connection terminated"); + + if ((cbd->flags & LUA_TCP_FLAG_FINISHED)) { + /* A callback has called `close` method, so we need to release a refcount */ + TCP_RELEASE (cbd); + } } lua_tcp_plan_handler_event (cbd, FALSE, FALSE); @@ -1067,6 +1072,11 @@ lua_tcp_process_read (struct lua_tcp_cbdata *cbd, lua_tcp_push_error (cbd, TRUE, "IO read error while trying to read data: %s", strerror (errno)); + + if ((cbd->flags & LUA_TCP_FLAG_FINISHED)) { + /* A callback has called `close` method, so we need to release a refcount */ + TCP_RELEASE (cbd); + } } lua_tcp_plan_handler_event (cbd, FALSE, FALSE); @@ -1193,8 +1203,8 @@ lua_tcp_plan_handler_event (struct lua_tcp_cbdata *cbd, gboolean can_read, if (!(cbd->flags & LUA_TCP_FLAG_FINISHED)) { /* We are finished with a connection */ msg_debug_tcp ("no handlers left, finish session"); - TCP_RELEASE (cbd); cbd->flags |= LUA_TCP_FLAG_FINISHED; + TCP_RELEASE (cbd); } } else { |