From 8303b194152ffc02b5079b6bd08f1fecfd43f5d0 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Thu, 23 May 2019 17:20:22 +0100 Subject: [PATCH] [Fix] Lua_tcp: Report connection failures Issue: #2899 --- src/lua/lua_tcp.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/lua/lua_tcp.c b/src/lua/lua_tcp.c index ccc4d59a1..1c789a9d3 100644 --- a/src/lua/lua_tcp.c +++ b/src/lua/lua_tcp.c @@ -1550,17 +1550,12 @@ lua_tcp_request (lua_State *L) lua_pop (L, 1); } else { - msg_err ("tcp request has bad params"); - lua_pushboolean (L, FALSE); - - return 1; + return luaL_error (L, "tcp request has bad params"); } if (resolver == NULL && cfg == NULL && task == NULL) { - msg_err ("tcp request has bad params: one of {resolver,task,config} should be set"); - lua_pushboolean (L, FALSE); - - return 1; + return luaL_error (L, "tcp request has bad params: one of " + "{resolver,task,config} should be set"); } cbd->task = task; @@ -1637,6 +1632,7 @@ lua_tcp_request (lua_State *L) cbd->session = session; if (rspamd_session_blocked (session)) { + lua_tcp_push_error (cbd, TRUE, "async session is the blocked state"); TCP_RELEASE (cbd); lua_pushboolean (L, FALSE); @@ -1650,6 +1646,7 @@ lua_tcp_request (lua_State *L) lua_tcp_register_watcher (cbd); if (!lua_tcp_make_connection (cbd)) { + lua_tcp_push_error (cbd, TRUE, "cannot connect to the host: %s", host); lua_pushboolean (L, FALSE); TCP_RELEASE (cbd); -- 2.39.5