commit cdf45ce: [Fix] Oops, fix maps reload
Vsevolod Stakhov
vsevolod at highsecure.ru
Fri Nov 8 16:21:06 UTC 2019
Author: Vsevolod Stakhov
Date: 2019-11-08 16:20:31 +0000
URL: https://github.com/rspamd/rspamd/commit/cdf45ced6793f066bd965336cf8d2f443807bcbd (HEAD -> master)
[Fix] Oops, fix maps reload
---
src/libutil/map.c | 13 +++++++++----
test/functional/cases/125_map_reload.robot | 1 -
2 files changed, 9 insertions(+), 5 deletions(-)
diff --git a/src/libutil/map.c b/src/libutil/map.c
index dcdb58f35..d8c990a76 100644
--- a/src/libutil/map.c
+++ b/src/libutil/map.c
@@ -1005,8 +1005,12 @@ rspamd_map_schedule_periodic (struct rspamd_map *map, int how)
gdouble timeout;
struct map_periodic_cbdata *cbd;
- if (map->scheduled_check || (map->wrk && map->wrk->state == rspamd_worker_state_running)) {
- /* Do not schedule check if some check is already scheduled */
+ if (map->scheduled_check || (map->wrk &&
+ map->wrk->state != rspamd_worker_state_running)) {
+ /*
+ * Do not schedule check if some check is already scheduled or
+ * if worker is going to die
+ */
return;
}
@@ -1860,7 +1864,8 @@ rspamd_map_process_periodic (struct map_periodic_cbdata *cbd)
map->scheduled_check = NULL;
if (!map->file_only && !cbd->locked) {
- if (!g_atomic_int_compare_and_exchange (cbd->map->locked, 0, 1)) {
+ if (!g_atomic_int_compare_and_exchange (cbd->map->locked,
+ 0, 1)) {
msg_debug_map (
"don't try to reread map %s as it is locked by other process, "
"will reread it later", cbd->map->name);
@@ -1901,7 +1906,7 @@ rspamd_map_process_periodic (struct map_periodic_cbdata *cbd)
return;
}
- if (!(cbd->map->wrk && cbd->map->wrk->state == rspamd_worker_state_running)) {
+ if (cbd->map->wrk && cbd->map->wrk->state == rspamd_worker_state_running) {
bk = g_ptr_array_index (cbd->map->backends, cbd->cur_backend);
g_assert (bk != NULL);
diff --git a/test/functional/cases/125_map_reload.robot b/test/functional/cases/125_map_reload.robot
index 2afaf2ab2..4973b090d 100644
--- a/test/functional/cases/125_map_reload.robot
+++ b/test/functional/cases/125_map_reload.robot
@@ -18,7 +18,6 @@ CHECK HIT AND MISS
Check Rspamc ${result} MAP_SET_HIT_AND_MISS (1.00)[example.com]
WRITE NEW MAP
- Sleep 1s Wait for new time
${TMP_FILE} = Make Temporary File
Copy File ${TESTDIR}/configs/maps/domains.list.2 ${TMP_FILE}
Move File ${TMP_FILE} ${MAP_FILE}
More information about the Commits
mailing list