aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2015-01-17 16:57:46 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2015-01-17 16:57:46 +0000
commit146debb5020659b4cbfdced4ca6d651de162dd4b (patch)
tree445bbe4fafd97613ec1062d614f478f2d5197442
parent343b21dd6bdc9ad877884b6bca69c190218ba533 (diff)
downloadrspamd-146debb5020659b4cbfdced4ca6d651de162dd4b.tar.gz
rspamd-146debb5020659b4cbfdced4ca6d651de162dd4b.zip
Revert "Preserve destructors order as LIFO."
That change was completely incorrect. This reverts commit 1f2c83f096f28ce79e828edd1ab545a341f10451.
-rw-r--r--src/libutil/mem_pool.c13
-rw-r--r--src/libutil/mem_pool.h2
2 files changed, 9 insertions, 6 deletions
diff --git a/src/libutil/mem_pool.c b/src/libutil/mem_pool.c
index a292c082a..6c9ee6f16 100644
--- a/src/libutil/mem_pool.c
+++ b/src/libutil/mem_pool.c
@@ -27,7 +27,6 @@
#include "fstring.h"
#include "logger.h"
#include "util.h"
-#include "utlist.h"
#include "main.h"
/* Sleep time for spin lock in nanoseconds */
@@ -541,7 +540,8 @@ rspamd_mempool_add_destructor_full (rspamd_mempool_t * pool,
cur->data = data;
cur->function = function;
cur->loc = line;
- DL_APPEND (pool->destructors, cur);
+ cur->prev = pool->destructors;
+ pool->destructors = cur;
POOL_MTX_UNLOCK ();
}
}
@@ -554,12 +554,14 @@ rspamd_mempool_replace_destructor (rspamd_mempool_t * pool,
{
struct _pool_destructors *tmp;
- DL_FOREACH (pool->destructors, tmp) {
+ tmp = pool->destructors;
+ while (tmp) {
if (tmp->func == func && tmp->data == old_data) {
tmp->func = func;
tmp->data = new_data;
break;
}
+ tmp = tmp->prev;
}
}
@@ -569,15 +571,16 @@ rspamd_mempool_delete (rspamd_mempool_t * pool)
{
struct _pool_chain *cur = pool->first_pool, *tmp;
struct _pool_chain_shared *cur_shared = pool->shared_pool, *tmp_shared;
- struct _pool_destructors *destructor;
+ struct _pool_destructors *destructor = pool->destructors;
POOL_MTX_LOCK ();
/* Call all pool destructors */
- DL_FOREACH (pool->destructors, destructor) {
+ while (destructor) {
/* Avoid calling destructors for NULL pointers */
if (destructor->data != NULL) {
destructor->func (destructor->data);
}
+ destructor = destructor->prev;
}
while (cur) {
diff --git a/src/libutil/mem_pool.h b/src/libutil/mem_pool.h
index 4552e8ca3..7403ced29 100644
--- a/src/libutil/mem_pool.h
+++ b/src/libutil/mem_pool.h
@@ -78,7 +78,7 @@ struct _pool_destructors {
void *data; /**< data to free */
const gchar *function; /**< function from which this destructor was added */
const gchar *loc; /**< line number */
- struct _pool_destructors *prev, *next; /**< chain link */
+ struct _pool_destructors *prev; /**< chain link */
};
/**