From: Vsevolod Stakhov Date: Thu, 13 Sep 2018 12:28:58 +0000 (+0100) Subject: [Minor] Another fix to lua_tcp watchers X-Git-Tag: 1.8.0~117 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=8adb4632a9869704776fccb4e40a48ef140f0be4;p=thirdparty%2Frspamd.git [Minor] Another fix to lua_tcp watchers --- diff --git a/src/lua/lua_tcp.c b/src/lua/lua_tcp.c index ef4b4cb5ad..b5b6eba5f9 100644 --- a/src/lua/lua_tcp.c +++ b/src/lua/lua_tcp.c @@ -1655,12 +1655,9 @@ lua_tcp_request (lua_State *L) rspamd_inet_address_set_port (cbd->addr, port); /* Host is numeric IP, no need to resolve */ if (!lua_tcp_make_connection (cbd)) { - TCP_RELEASE (cbd); lua_pushboolean (L, FALSE); - if (cbd->w) { - rspamd_session_watcher_pop (cbd->session, cbd->w); - } + TCP_RELEASE (cbd); return 1; } @@ -1670,12 +1667,9 @@ lua_tcp_request (lua_State *L) if (!make_dns_request (resolver, session, NULL, lua_tcp_dns_handler, cbd, RDNS_REQUEST_A, host)) { lua_tcp_push_error (cbd, TRUE, "cannot resolve host: %s", host); - TCP_RELEASE (cbd); lua_pushboolean (L, FALSE); - if (cbd->w) { - rspamd_session_watcher_pop (cbd->session, cbd->w); - } + TCP_RELEASE (cbd); return 1; } @@ -1684,12 +1678,9 @@ lua_tcp_request (lua_State *L) if (!make_dns_request_task (task, lua_tcp_dns_handler, cbd, RDNS_REQUEST_A, host)) { lua_tcp_push_error (cbd, TRUE, "cannot resolve host: %s", host); - TCP_RELEASE (cbd); lua_pushboolean (L, FALSE); - if (cbd->w) { - rspamd_session_watcher_pop (cbd->session, cbd->w); - } + TCP_RELEASE (cbd); return 1; } @@ -1827,13 +1818,10 @@ lua_tcp_connect_sync (lua_State *L) rspamd_inet_address_set_port (cbd->addr, (guint16)port); /* Host is numeric IP, no need to resolve */ if (!lua_tcp_make_connection (cbd)) { - TCP_RELEASE (cbd); lua_pushboolean (L, FALSE); lua_pushliteral (L, "Failed to initiate connection"); - if (cbd->w) { - rspamd_session_watcher_pop (cbd->session, cbd->w); - } + TCP_RELEASE (cbd); return 2; } @@ -1842,13 +1830,10 @@ lua_tcp_connect_sync (lua_State *L) if (task == NULL) { if (!make_dns_request (resolver, session, NULL, lua_tcp_dns_handler, cbd, RDNS_REQUEST_A, host)) { - TCP_RELEASE (cbd); lua_pushboolean (L, FALSE); lua_pushliteral (L, "Failed to initiate dns request"); - if (cbd->w) { - rspamd_session_watcher_pop (cbd->session, cbd->w); - } + TCP_RELEASE (cbd); return 2; } @@ -1856,13 +1841,9 @@ lua_tcp_connect_sync (lua_State *L) else { if (!make_dns_request_task (task, lua_tcp_dns_handler, cbd, RDNS_REQUEST_A, host)) { - TCP_RELEASE (cbd); lua_pushboolean (L, FALSE); lua_pushliteral (L, "Failed to initiate dns request"); - - if (cbd->w) { - rspamd_session_watcher_pop (cbd->session, cbd->w); - } + TCP_RELEASE (cbd); return 2; }