summaryrefslogtreecommitdiffstats
path: root/src/mem_pool.c
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@rambler-co.ru>2012-09-19 17:15:30 +0400
committerVsevolod Stakhov <vsevolod@rambler-co.ru>2012-09-19 17:15:30 +0400
commit1bdd1f05773d1f16f4fc271e09a691a1750e0ed5 (patch)
treea50d6e7dd162c7f6891f52269bd04b74f67fe5c2 /src/mem_pool.c
parent9942bf2d277be84a322cdd3713cc51b8c6a1ec89 (diff)
downloadrspamd-1bdd1f05773d1f16f4fc271e09a691a1750e0ed5.tar.gz
rspamd-1bdd1f05773d1f16f4fc271e09a691a1750e0ed5.zip
Use universal mutex type to avoid glib collisions.
Diffstat (limited to 'src/mem_pool.c')
-rw-r--r--src/mem_pool.c21
1 files changed, 5 insertions, 16 deletions
diff --git a/src/mem_pool.c b/src/mem_pool.c
index dc57e3b79..6038ff604 100644
--- a/src/mem_pool.c
+++ b/src/mem_pool.c
@@ -26,6 +26,7 @@
#include "mem_pool.h"
#include "fstring.h"
#include "logger.h"
+#include "util.h"
#include "main.h"
/* Sleep time for spin lock in nanoseconds */
@@ -41,13 +42,8 @@ pthread_mutex_t stat_mtx = PTHREAD_MUTEX_INITIALIZER;
# define STAT_UNLOCK() do {} while (0)
#endif
-#if ((GLIB_MAJOR_VERSION == 2) && (GLIB_MINOR_VERSION <= 30))
-# define POOL_MTX_LOCK() do { g_static_mutex_lock (&pool->mtx); } while (0)
-# define POOL_MTX_UNLOCK() do { g_static_mutex_unlock (&pool->mtx); } while (0)
-#else
-# define POOL_MTX_LOCK() do { g_mutex_lock (&pool->mtx); } while (0)
-# define POOL_MTX_UNLOCK() do { g_mutex_unlock (&pool->mtx); } while (0)
-#endif
+#define POOL_MTX_LOCK() do { rspamd_mutex_lock (pool->mtx); } while (0)
+#define POOL_MTX_UNLOCK() do { rspamd_mutex_unlock (pool->mtx); } while (0)
/*
* This define specify whether we should check all pools for free space for new object
@@ -200,11 +196,7 @@ memory_pool_new (gsize size)
new->destructors = NULL;
/* Set it upon first call of set variable */
new->variables = NULL;
-#if ((GLIB_MAJOR_VERSION == 2) && (GLIB_MINOR_VERSION <= 30))
- g_static_mutex_init (&new->mtx);
-#else
- g_mutex_init (&new->mtx);
-#endif
+ new->mtx = rspamd_mutex_new ();
mem_pool_stat->pools_allocated++;
@@ -620,10 +612,7 @@ memory_pool_delete (memory_pool_t * pool)
mem_pool_stat->pools_freed++;
POOL_MTX_UNLOCK ();
-#if ((GLIB_MAJOR_VERSION == 2) && (GLIB_MINOR_VERSION > 30))
- g_mutex_clear (&pool->mtx);
-#endif
- g_slice_free (memory_pool_t, pool);
+ rspamd_mutex_free (pool->mtx);
}
void