aboutsummaryrefslogtreecommitdiffstats
path: root/src/lua/lua_redis.c
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@rambler-co.ru>2012-08-22 21:41:48 +0400
committerVsevolod Stakhov <vsevolod@rambler-co.ru>2012-08-22 21:41:48 +0400
commitb90267a71cc8cdc8b38675322ef9fa7a9cb5468c (patch)
tree3bff8af523d19ec9cff93134b067fc404795000d /src/lua/lua_redis.c
parented224e6a3530f54b5993e39066a8397d54e9517e (diff)
downloadrspamd-b90267a71cc8cdc8b38675322ef9fa7a9cb5468c.tar.gz
rspamd-b90267a71cc8cdc8b38675322ef9fa7a9cb5468c.zip
* Rework thread pools locking logic to avoid global lua mutex usage.
Fixed several memory leaks with modern glib. Fixed memory leak in dkim code. Fixed a problem with static global variables in shared libraries.
Diffstat (limited to 'src/lua/lua_redis.c')
-rw-r--r--src/lua/lua_redis.c17
1 files changed, 0 insertions, 17 deletions
diff --git a/src/lua/lua_redis.c b/src/lua/lua_redis.c
index 2e6211078..e312092cb 100644
--- a/src/lua/lua_redis.c
+++ b/src/lua/lua_redis.c
@@ -83,9 +83,7 @@ lua_redis_fin (void *arg)
if (ud->ctx) {
redisAsyncFree (ud->ctx);
- g_mutex_lock (lua_mtx);
luaL_unref (ud->L, LUA_REGISTRYINDEX, ud->cbref);
- g_mutex_unlock (lua_mtx);
}
}
@@ -98,12 +96,7 @@ static void
lua_redis_push_error (const gchar *err, struct lua_redis_userdata *ud, gboolean connected)
{
struct worker_task **ptask;
- gboolean need_unlock = FALSE;
- /* Avoid LOR here as mutex can be acquired before in lua_call */
- if (g_mutex_trylock (lua_mtx)) {
- need_unlock = TRUE;
- }
/* Push error */
lua_rawgeti (ud->L, LUA_REGISTRYINDEX, ud->cbref);
ptask = lua_newuserdata (ud->L, sizeof (struct worker_task *));
@@ -117,9 +110,6 @@ lua_redis_push_error (const gchar *err, struct lua_redis_userdata *ud, gboolean
if (lua_pcall (ud->L, 3, 0, 0) != 0) {
msg_info ("call to callback failed: %s", lua_tostring (ud->L, -1));
}
- if (need_unlock) {
- g_mutex_unlock (lua_mtx);
- }
if (connected) {
remove_normal_event (ud->task->s, lua_redis_fin, ud);
@@ -136,11 +126,7 @@ static void
lua_redis_push_data (const redisReply *r, struct lua_redis_userdata *ud)
{
struct worker_task **ptask;
- gboolean need_unlock = FALSE;
- if (g_mutex_trylock (lua_mtx)) {
- need_unlock = TRUE;
- }
/* Push error */
lua_rawgeti (ud->L, LUA_REGISTRYINDEX, ud->cbref);
ptask = lua_newuserdata (ud->L, sizeof (struct worker_task *));
@@ -170,9 +156,6 @@ lua_redis_push_data (const redisReply *r, struct lua_redis_userdata *ud)
if (lua_pcall (ud->L, 3, 0, 0) != 0) {
msg_info ("call to callback failed: %s", lua_tostring (ud->L, -1));
}
- if (need_unlock) {
- g_mutex_unlock (lua_mtx);
- }
remove_normal_event (ud->task->s, lua_redis_fin, ud);
}