]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] Another fix to lua_tcp watchers
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Thu, 13 Sep 2018 12:28:58 +0000 (13:28 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Thu, 13 Sep 2018 12:28:58 +0000 (13:28 +0100)
src/lua/lua_tcp.c

index ef4b4cb5ad21acf83393032be90fed2948a9d034..b5b6eba5f99f7baa1b351c2fabd82dad41df1c5e 100644 (file)
@@ -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;
                        }