aboutsummaryrefslogtreecommitdiffstats
path: root/src/libserver/maps
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2022-02-12 13:03:15 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2022-02-12 13:03:58 +0000
commit4ebb7dcf7fce6459c6d60813d136074c75700240 (patch)
tree449378bf2b9a8c0a33a8c2b394c81b4b5f9e8837 /src/libserver/maps
parentb00071d015999d500116ff026b209a7f4d758cdb (diff)
downloadrspamd-4ebb7dcf7fce6459c6d60813d136074c75700240.tar.gz
rspamd-4ebb7dcf7fce6459c6d60813d136074c75700240.zip
[Fix] Fix http maps shared memory cache cleanup
It must be initiated by active http worker as it really has the shm object available.
Diffstat (limited to 'src/libserver/maps')
-rw-r--r--src/libserver/maps/map.c31
1 files changed, 18 insertions, 13 deletions
diff --git a/src/libserver/maps/map.c b/src/libserver/maps/map.c
index 6348ca8b2..19c6c6e6c 100644
--- a/src/libserver/maps/map.c
+++ b/src/libserver/maps/map.c
@@ -2521,20 +2521,25 @@ rspamd_map_backend_dtor (struct rspamd_map_backend *bk)
rspamd_fstring_free (data->etag);
}
- if (g_atomic_int_compare_and_exchange (&data->cache->available, 1, 0)) {
- if (data->cur_cache_cbd) {
- msg_info ("clear shared memory cache for a map in %s on backend %s closing",
- data->cur_cache_cbd->shm->shm_name,
- bk->uri);
- MAP_RELEASE (data->cur_cache_cbd->shm,
- "rspamd_http_map_cached_cbdata");
- ev_timer_stop (data->cur_cache_cbd->event_loop,
- &data->cur_cache_cbd->timeout);
- g_free (data->cur_cache_cbd);
- data->cur_cache_cbd = NULL;
+ /*
+ * Clear cached file, but check if a worker is an active http worker
+ * as cur_cache_cbd is meaningful merely for active worker, who actually
+ * owns the cache
+ */
+ if (bk->map && bk->map->active_http) {
+ if (g_atomic_int_compare_and_exchange (&data->cache->available, 1, 0)) {
+ if (data->cur_cache_cbd) {
+ msg_info ("clear shared memory cache for a map in %s as backend \"%s\" is closing",
+ data->cur_cache_cbd->shm->shm_name,
+ bk->uri);
+ MAP_RELEASE (data->cur_cache_cbd->shm,
+ "rspamd_http_map_cached_cbdata");
+ ev_timer_stop (data->cur_cache_cbd->event_loop,
+ &data->cur_cache_cbd->timeout);
+ g_free (data->cur_cache_cbd);
+ data->cur_cache_cbd = NULL;
+ }
}
-
- unlink (data->cache->shmem_name);
}
g_free (bk->data.hd);