]> source.dussan.org Git - rspamd.git/commitdiff
[Fix] Oops, fix maps reload
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Fri, 8 Nov 2019 16:20:31 +0000 (16:20 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Fri, 8 Nov 2019 16:20:31 +0000 (16:20 +0000)
src/libutil/map.c
test/functional/cases/125_map_reload.robot

index dcdb58f351d45ffc5c836f61f34f6f0ac44bd3fb..d8c990a768538a3b4d0eac0108129a21f4f008d8 100644 (file)
@@ -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);
 
index 2afaf2ab272982ce186b51dd23c06ce057934e66..4973b090d1c04a41d476002f90515af3aad144ac 100644 (file)
@@ -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}