summaryrefslogtreecommitdiffstats
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
parent9942bf2d277be84a322cdd3713cc51b8c6a1ec89 (diff)
downloadrspamd-1bdd1f05773d1f16f4fc271e09a691a1750e0ed5.tar.gz
rspamd-1bdd1f05773d1f16f4fc271e09a691a1750e0ed5.zip
Use universal mutex type to avoid glib collisions.
-rw-r--r--src/mem_pool.c21
-rw-r--r--src/mem_pool.h7
2 files changed, 7 insertions, 21 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
diff --git a/src/mem_pool.h b/src/mem_pool.h
index 79d9d48fe..5bef5fee1 100644
--- a/src/mem_pool.h
+++ b/src/mem_pool.h
@@ -70,6 +70,7 @@ struct _pool_destructors {
/**
* Memory pool type
*/
+struct rspamd_mutex_s;
typedef struct memory_pool_s {
struct _pool_chain *cur_pool; /**< currently used page */
struct _pool_chain *first_pool; /**< first page */
@@ -78,11 +79,7 @@ typedef struct memory_pool_s {
struct _pool_chain_shared *shared_pool; /**< shared chain */
struct _pool_destructors *destructors; /**< destructors chain */
GHashTable *variables; /**< private memory pool variables */
-#if ((GLIB_MAJOR_VERSION == 2) && (GLIB_MINOR_VERSION <= 30))
- GStaticMutex mtx; /**< threads lock */
-#else
- GMutex mtx; /**< threads lock */
-#endif
+ struct rspamd_mutex_s *mtx; /**< threads lock */
} memory_pool_t;
/**