summaryrefslogtreecommitdiffstats
path: root/src/lua
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@rspamd.com>2023-09-09 15:46:59 +0100
committerVsevolod Stakhov <vsevolod@rspamd.com>2023-09-09 15:46:59 +0100
commitf5e3fbebb9baee8dc25ff3312aaa05c84b7ab55e (patch)
tree481108839bcff1db500f43724347e5aaf48ba0fa /src/lua
parent0b51255f334ced4362257fc2c93a48489c2ec55e (diff)
downloadrspamd-f5e3fbebb9baee8dc25ff3312aaa05c84b7ab55e.tar.gz
rspamd-f5e3fbebb9baee8dc25ff3312aaa05c84b7ab55e.zip
[Minor] Slightly improve logging
Diffstat (limited to 'src/lua')
-rw-r--r--src/lua/lua_http.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/lua/lua_http.c b/src/lua/lua_http.c
index ba69b9f60..713082ac5 100644
--- a/src/lua/lua_http.c
+++ b/src/lua/lua_http.c
@@ -1,11 +1,11 @@
-/*-
- * Copyright 2016 Vsevolod Stakhov
+/*
+ * Copyright 2023 Vsevolod Stakhov
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -677,6 +677,8 @@ lua_http_request(lua_State *L)
msg = rspamd_http_message_from_url(url);
if (msg == NULL) {
+ luaL_unref(L, LUA_REGISTRYINDEX, cbref);
+ msg_err("cannot create HTTP message from url %s", url);
lua_pushboolean(L, FALSE);
return 1;
}
@@ -687,6 +689,12 @@ lua_http_request(lua_State *L)
url = luaL_checkstring(L, -1);
lua_pop(L, 1);
+ if (url == NULL) {
+ msg_err("cannot create HTTP message without url");
+ lua_pushboolean(L, FALSE);
+ return 1;
+ }
+
lua_pushstring(L, "callback");
lua_gettable(L, 1);
if (url == NULL || lua_type(L, -1) != LUA_TFUNCTION) {
@@ -763,7 +771,7 @@ lua_http_request(lua_State *L)
msg = rspamd_http_message_from_url(url);
if (msg == NULL) {
- msg_err("cannot create HTTP message from url %s", url);
+ msg_err_task_check("cannot create HTTP message from url %s", url);
lua_pushboolean(L, FALSE);
return 1;
}