commit 7157661: [Minor] Core: Try to avoid race when cleaning maps up
Vsevolod Stakhov
vsevolod at highsecure.ru
Tue Jan 22 10:14:03 UTC 2019
Author: Vsevolod Stakhov
Date: 2019-01-22 10:03:09 +0000
URL: https://github.com/rspamd/rspamd/commit/7157661c6ff00ea27466caba3e05c5d65f819ee9 (HEAD -> master)
[Minor] Core: Try to avoid race when cleaning maps up
---
src/libutil/map_helpers.c | 18 ++++++++++++------
1 file changed, 12 insertions(+), 6 deletions(-)
diff --git a/src/libutil/map_helpers.c b/src/libutil/map_helpers.c
index cc8002eac..4b2b41fcb 100644
--- a/src/libutil/map_helpers.c
+++ b/src/libutil/map_helpers.c
@@ -640,12 +640,14 @@ rspamd_map_helper_new_hash (struct rspamd_map *map)
void
rspamd_map_helper_destroy_hash (struct rspamd_hash_map_helper *r)
{
- if (r == NULL) {
+ if (r == NULL || r->pool == NULL) {
return;
}
+ rspamd_mempool_t *pool = r->pool;
kh_destroy (rspamd_map_hash, r->htb);
- rspamd_mempool_delete (r->pool);
+ memset (r, 0, sizeof (*r));
+ rspamd_mempool_delete (pool);
}
static void
@@ -696,12 +698,14 @@ rspamd_map_helper_new_radix (struct rspamd_map *map)
void
rspamd_map_helper_destroy_radix (struct rspamd_radix_map_helper *r)
{
- if (r == NULL) {
+ if (r == NULL || !r->pool) {
return;
}
kh_destroy (rspamd_map_hash, r->htb);
- rspamd_mempool_delete (r->pool);
+ rspamd_mempool_t *pool = r->pool;
+ memset (r, 0, sizeof (*r));
+ rspamd_mempool_delete (pool);
}
static void
@@ -754,7 +758,7 @@ rspamd_map_helper_destroy_regexp (struct rspamd_regexp_map_helper *re_map)
rspamd_regexp_t *re;
guint i;
- if (!re_map) {
+ if (!re_map || !re_map->regexps) {
return;
}
@@ -785,7 +789,9 @@ rspamd_map_helper_destroy_regexp (struct rspamd_regexp_map_helper *re_map)
}
#endif
- rspamd_mempool_delete (re_map->pool);
+ rspamd_mempool_t *pool = re_map->pool;
+ memset (re_map, 0, sizeof (*re_map));
+ rspamd_mempool_delete (pool);
}
gchar *
More information about the Commits
mailing list