diff options
author | Vsevolod Stakhov <vsevolod@rambler-co.ru> | 2012-08-22 21:41:48 +0400 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@rambler-co.ru> | 2012-08-22 21:41:48 +0400 |
commit | b90267a71cc8cdc8b38675322ef9fa7a9cb5468c (patch) | |
tree | 3bff8af523d19ec9cff93134b067fc404795000d /src/lua/lua_buffer.c | |
parent | ed224e6a3530f54b5993e39066a8397d54e9517e (diff) | |
download | rspamd-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_buffer.c')
-rw-r--r-- | src/lua/lua_buffer.c | 28 |
1 files changed, 2 insertions, 26 deletions
diff --git a/src/lua/lua_buffer.c b/src/lua/lua_buffer.c index 43df6a6d8..b7a460b52 100644 --- a/src/lua/lua_buffer.c +++ b/src/lua/lua_buffer.c @@ -82,13 +82,9 @@ static gboolean lua_io_read_cb (f_str_t * in, void *arg) { struct lua_dispatcher_cbdata *cbdata = arg; - gboolean need_unlock = FALSE, res; + gboolean res; rspamd_io_dispatcher_t **pdispatcher; - /* Avoid LOR here as mutex can be acquired before in lua_call */ - if (g_mutex_trylock (lua_mtx)) { - need_unlock = TRUE; - } /* callback (dispatcher, data) */ lua_rawgeti (cbdata->L, LUA_REGISTRYINDEX, cbdata->cbref_read); pdispatcher = lua_newuserdata (cbdata->L, sizeof (struct rspamd_io_dispatcher_s *)); @@ -103,10 +99,6 @@ lua_io_read_cb (f_str_t * in, void *arg) res = lua_toboolean (cbdata->L, -1); lua_pop (cbdata->L, 1); - if (need_unlock) { - g_mutex_unlock (lua_mtx); - } - return res; } @@ -114,14 +106,10 @@ static gboolean lua_io_write_cb (void *arg) { struct lua_dispatcher_cbdata *cbdata = arg; - gboolean need_unlock = FALSE, res; + gboolean res; rspamd_io_dispatcher_t **pdispatcher; if (cbdata->cbref_write) { - /* Avoid LOR here as mutex can be acquired before in lua_call */ - if (g_mutex_trylock (lua_mtx)) { - need_unlock = TRUE; - } lua_rawgeti (cbdata->L, LUA_REGISTRYINDEX, cbdata->cbref_read); /* callback (dispatcher) */ pdispatcher = lua_newuserdata (cbdata->L, sizeof (struct rspamd_io_dispatcher_s *)); @@ -135,10 +123,6 @@ lua_io_write_cb (void *arg) res = lua_toboolean (cbdata->L, -1); lua_pop (cbdata->L, 1); - - if (need_unlock) { - g_mutex_unlock (lua_mtx); - } } return res; @@ -148,13 +132,8 @@ static void lua_io_err_cb (GError * err, void *arg) { struct lua_dispatcher_cbdata *cbdata = arg; - gboolean need_unlock = FALSE; rspamd_io_dispatcher_t **pdispatcher; - /* Avoid LOR here as mutex can be acquired before in lua_call */ - if (g_mutex_trylock (lua_mtx)) { - need_unlock = TRUE; - } /* callback (dispatcher, err) */ lua_rawgeti (cbdata->L, LUA_REGISTRYINDEX, cbdata->cbref_err); pdispatcher = lua_newuserdata (cbdata->L, sizeof (struct rspamd_io_dispatcher_s *)); @@ -166,9 +145,6 @@ lua_io_err_cb (GError * err, void *arg) msg_info ("call to session finalizer failed: %s", lua_tostring (cbdata->L, -1)); } - if (need_unlock) { - g_mutex_unlock (lua_mtx); - } /* Unref callbacks */ luaL_unref (cbdata->L, LUA_REGISTRYINDEX, cbdata->cbref_read); if (cbdata->cbref_write) { |