diff options
author | Vsevolod Stakhov <vsevolod@rambler-co.ru> | 2012-02-13 21:51:10 +0400 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@rambler-co.ru> | 2012-02-13 21:51:10 +0400 |
commit | a5b48a05a94d178c342bbad69a330addb518d148 (patch) | |
tree | ee7ab452cd4a98fdb7503e78cc52a3d4f66dd27e /src/lua/lua_classifier.c | |
parent | 0d64c808b7310b6e233ec570649fbb281a3f2b13 (diff) | |
download | rspamd-a5b48a05a94d178c342bbad69a330addb518d148.tar.gz rspamd-a5b48a05a94d178c342bbad69a330addb518d148.zip |
* More things to be thread-safe:
- pool allocator is now thread-safe
- lua subsystem now holds lock to avoid lua stack corruption
- events subsystem now using conditional variables to wait for async_threads
- insert_result is thread-safe now
Diffstat (limited to 'src/lua/lua_classifier.c')
-rw-r--r-- | src/lua/lua_classifier.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/lua/lua_classifier.c b/src/lua/lua_classifier.c index 0bf0daca8..edaf4e7a6 100644 --- a/src/lua/lua_classifier.c +++ b/src/lua/lua_classifier.c @@ -123,6 +123,7 @@ call_classifier_pre_callbacks (struct classifier_config *ccf, struct worker_task struct classifier_callback_data *cd; lua_State *L; + /* Go throught all callbacks and call them, appending results to list */ cur = g_list_first (ccf->pre_callbacks); while (cur) { @@ -134,6 +135,7 @@ call_classifier_pre_callbacks (struct classifier_config *ccf, struct worker_task cur = g_list_next (cur); } + g_mutex_lock (lua_mtx); if (res == NULL) { L = task->cfg->lua_state; /* Check function from global table 'classifiers' */ @@ -149,6 +151,8 @@ call_classifier_pre_callbacks (struct classifier_config *ccf, struct worker_task } lua_pop (L, 1); } + g_mutex_unlock (lua_mtx); + return res; } @@ -162,6 +166,7 @@ call_classifier_post_callbacks (struct classifier_config *ccf, struct worker_tas double out = in; GList *cur; + g_mutex_lock (lua_mtx); /* Go throught all callbacks and call them, appending results to list */ cur = g_list_first (ccf->pre_callbacks); while (cur) { @@ -190,6 +195,7 @@ call_classifier_post_callbacks (struct classifier_config *ccf, struct worker_tas cur = g_list_next (cur); } + g_mutex_unlock (lua_mtx); return out; |