aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2016-05-07 13:33:05 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2016-05-07 13:33:05 +0100
commiteb5d274ab5466012ec3cb019e08d3436c66211d5 (patch)
tree38dff490b1c10b24874d47d9a445098de7766628
parent52b508ca0086d76a63229dc648c7bad421a5cd0c (diff)
downloadrspamd-eb5d274ab5466012ec3cb019e08d3436c66211d5.tar.gz
rspamd-eb5d274ab5466012ec3cb019e08d3436c66211d5.zip
[Feature] Better lua_redis logging
-rw-r--r--src/lua/lua_redis.c20
1 files changed, 15 insertions, 5 deletions
diff --git a/src/lua/lua_redis.c b/src/lua/lua_redis.c
index f899fa96b..c35d9614b 100644
--- a/src/lua/lua_redis.c
+++ b/src/lua/lua_redis.c
@@ -607,7 +607,7 @@ lua_redis_make_request (lua_State *L)
luaL_unref (L, LUA_REGISTRYINDEX, cbref);
}
- msg_err ("incorrect function invocation");
+ msg_err_task_check ("incorrect function invocation");
}
}
else if ((task = lua_check_task (L, 1)) != NULL) {
@@ -655,7 +655,7 @@ lua_redis_make_request (lua_State *L)
ret = TRUE;
}
else {
- msg_err ("incorrect function invocation");
+ msg_err_task_check ("incorrect function invocation");
}
}
@@ -667,9 +667,14 @@ lua_redis_make_request (lua_State *L)
if (ud->ctx == NULL || ud->ctx->err) {
if (ud->ctx) {
+ msg_err_task_check ("cannot connect to redis: %s",
+ ud->ctx->errstr);
redisAsyncFree (ud->ctx);
ud->ctx = NULL;
}
+ else {
+ msg_err_task_check ("cannot connect to redis: unknown error");
+ }
REDIS_RELEASE (ctx);
lua_pushboolean (L, FALSE);
@@ -713,7 +718,7 @@ lua_redis_make_request (lua_State *L)
ret = TRUE;
}
else {
- msg_info ("call to redis failed: %s", ud->ctx->errstr);
+ msg_info_task_check ("call to redis failed: %s", ud->ctx->errstr);
redisAsyncFree (ud->ctx);
ud->ctx = NULL;
REDIS_RELEASE (ctx);
@@ -724,7 +729,6 @@ lua_redis_make_request (lua_State *L)
lua_pushboolean (L, ret);
if (ret) {
-
pctx = lua_newuserdata (L, sizeof (ctx));
*pctx = ctx;
rspamd_lua_setclass (L, "rspamd{redis}", -1);
@@ -936,6 +940,8 @@ lua_redis_connect (lua_State *L)
rspamd_inet_address_get_port (addr->addr));
if (ud->ctx == NULL || ud->ctx->err) {
+ msg_err_task_check ("cannot connect to redis: %s",
+ ud->ctx->errstr);
REDIS_RELEASE (ctx);
lua_pushboolean (L, FALSE);
@@ -1068,10 +1074,13 @@ lua_redis_add_cmd (lua_State *L)
guint nargs = 0;
gint cbref = -1, ret;
struct timeval tv;
+ struct rspamd_task *task;
if (ctx) {
if (ctx->async) {
+ task = ctx->d.async.task;
+
/* Async version */
if (lua_type (L, 2) == LUA_TSTRING) {
/* No callback version */
@@ -1121,7 +1130,8 @@ lua_redis_add_cmd (lua_State *L)
ctx->cmds_pending ++;
}
else {
- msg_info ("call to redis failed: %s", sp_ud->c->ctx->errstr);
+ msg_info_task_check ("call to redis failed: %s",
+ sp_ud->c->ctx->errstr);
lua_pushboolean (L, 0);
lua_pushstring (L, sp_ud->c->ctx->errstr);
return 2;