diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2018-08-14 12:51:54 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2018-08-14 12:51:54 +0100 |
commit | 1af89c35663dd364c8d46523f0d71adc64f8bde4 (patch) | |
tree | 1a814dea5f5ce6045bd53f2e802dd3eb87123ca0 /src/lua/lua_tcp.c | |
parent | 0478b4ee28138a886f9b457bdba7f2897e151093 (diff) | |
download | rspamd-1af89c35663dd364c8d46523f0d71adc64f8bde4.tar.gz rspamd-1af89c35663dd364c8d46523f0d71adc64f8bde4.zip |
[Fix] Add fail-safety for destroying sessions
Diffstat (limited to 'src/lua/lua_tcp.c')
-rw-r--r-- | src/lua/lua_tcp.c | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/src/lua/lua_tcp.c b/src/lua/lua_tcp.c index 6c3f6ec04..797bdcc4e 100644 --- a/src/lua/lua_tcp.c +++ b/src/lua/lua_tcp.c @@ -804,7 +804,8 @@ lua_tcp_plan_handler_event (struct lua_tcp_cbdata *cbd, gboolean can_read, } } -static void + +static gboolean lua_tcp_register_event (struct lua_tcp_cbdata *cbd) { if (cbd->session) { @@ -812,9 +813,16 @@ lua_tcp_register_event (struct lua_tcp_cbdata *cbd) (event_finalizer_t) lua_tcp_fin, cbd, g_quark_from_static_string ("lua tcp")); + + if (!cbd->async_ev) { + return FALSE; + } + cbd->w = rspamd_session_get_watcher (cbd->session); rspamd_session_watcher_push (cbd->session); } + + return TRUE; } static gboolean @@ -1232,6 +1240,13 @@ lua_tcp_request (lua_State *L) if (session) { cbd->session = session; + + if (rspamd_session_is_destroying (session)) { + REF_RELEASE (cbd); + lua_pushboolean (L, FALSE); + + return 1; + } } if (rspamd_parse_inet_address (&cbd->addr, host, 0)) { |