diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2019-06-27 11:17:42 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2019-06-27 11:17:42 +0100 |
commit | a5f75e4a3fb4e6562c09799f01d9af6107450e01 (patch) | |
tree | a9ce1c11ca8f8bb92eb7e0f3b2f0356ab72ccae5 /src | |
parent | b7dbb7d1c7ca8716996b324e6e16de87c6646d7c (diff) | |
download | rspamd-a5f75e4a3fb4e6562c09799f01d9af6107450e01.tar.gz rspamd-a5f75e4a3fb4e6562c09799f01d9af6107450e01.zip |
[Fix] Fix alignment mess
Issue: #2945
Diffstat (limited to 'src')
-rw-r--r-- | src/libcryptobox/cryptobox.h | 4 | ||||
-rw-r--r-- | src/libserver/worker_util.c | 4 | ||||
-rw-r--r-- | src/libutil/mem_pool.c | 12 | ||||
-rw-r--r-- | src/libutil/mem_pool.h | 16 |
4 files changed, 20 insertions, 16 deletions
diff --git a/src/libcryptobox/cryptobox.h b/src/libcryptobox/cryptobox.h index b78830ae1..adf490794 100644 --- a/src/libcryptobox/cryptobox.h +++ b/src/libcryptobox/cryptobox.h @@ -353,8 +353,8 @@ enum rspamd_cryptobox_fast_hash_type { }; /* Non crypto hash IUF interface */ -typedef struct RSPAMD_ALIGNED(16) rspamd_cryptobox_fast_hash_state_s { - RSPAMD_ALIGNED(16) guint64 opaque[11]; +typedef struct rspamd_cryptobox_fast_hash_state_s { + guint64 opaque[11]; enum rspamd_cryptobox_fast_hash_type type; } rspamd_cryptobox_fast_hash_state_t; diff --git a/src/libserver/worker_util.c b/src/libserver/worker_util.c index 5c5d41b90..3ad528d1e 100644 --- a/src/libserver/worker_util.c +++ b/src/libserver/worker_util.c @@ -57,6 +57,10 @@ #include <sys/ucontext.h> #endif +#ifdef HAVE_SYS_WAIT_H +#include <sys/wait.h> +#endif + #include "contrib/libev/ev.h" static void rspamd_worker_ignore_signal (struct rspamd_worker_signal_handler *); diff --git a/src/libutil/mem_pool.c b/src/libutil/mem_pool.c index b7ce281c4..c03e7ae2c 100644 --- a/src/libutil/mem_pool.c +++ b/src/libutil/mem_pool.c @@ -105,7 +105,7 @@ static gboolean always_malloc = FALSE; static gsize pool_chain_free (struct _pool_chain *chain) { - gint64 occupied = chain->pos - chain->begin + MEM_ALIGNMENT; + gint64 occupied = chain->pos - chain->begin + MIN_MEM_ALIGNMENT; return (occupied < (gint64)chain->slice_size ? chain->slice_size - occupied : 0); @@ -169,7 +169,7 @@ static struct _pool_chain * rspamd_mempool_chain_new (gsize size, enum rspamd_mempool_chain_type pool_type) { struct _pool_chain *chain; - gsize total_size = size + sizeof (struct _pool_chain) + MEM_ALIGNMENT, + gsize total_size = size + sizeof (struct _pool_chain) + MIN_MEM_ALIGNMENT, optimal_size = 0; gpointer map; @@ -235,7 +235,7 @@ rspamd_mempool_chain_new (gsize size, enum rspamd_mempool_chain_type pool_type) g_atomic_int_inc (&mem_pool_stat->chunks_allocated); } - chain->pos = align_ptr (chain->begin, MEM_ALIGNMENT); + chain->pos = align_ptr (chain->begin, MIN_MEM_ALIGNMENT); chain->slice_size = total_size - sizeof (struct _pool_chain); chain->lock = NULL; @@ -369,7 +369,7 @@ rspamd_mempool_new_ (gsize size, const gchar *tag, const gchar *loc) static void * memory_pool_alloc_common (rspamd_mempool_t * pool, gsize size, enum rspamd_mempool_chain_type pool_type) -RSPAMD_ATTR_ALLOC_SIZE(2) RSPAMD_ATTR_ALLOC_ALIGN(MEM_ALIGNMENT) RSPAMD_ATTR_RETURNS_NONNUL; +RSPAMD_ATTR_ALLOC_SIZE(2) RSPAMD_ATTR_ALLOC_ALIGN(MIN_MEM_ALIGNMENT) RSPAMD_ATTR_RETURNS_NONNUL; static void * memory_pool_alloc_common (rspamd_mempool_t * pool, gsize size, @@ -405,7 +405,7 @@ memory_pool_alloc_common (rspamd_mempool_t * pool, gsize size, if (cur == NULL || free < size) { /* Allocate new chain element */ - if (pool->elt_len >= size + MEM_ALIGNMENT) { + if (pool->elt_len >= size + MIN_MEM_ALIGNMENT) { pool->entry->elts[pool->entry->cur_elts].fragmentation += size; new = rspamd_mempool_chain_new (pool->elt_len, pool_type); @@ -429,7 +429,7 @@ memory_pool_alloc_common (rspamd_mempool_t * pool, gsize size, } /* No need to allocate page */ - tmp = align_ptr (cur->pos, MEM_ALIGNMENT); + tmp = align_ptr (cur->pos, MIN_MEM_ALIGNMENT); cur->pos = tmp + size; POOL_MTX_UNLOCK (); diff --git a/src/libutil/mem_pool.h b/src/libutil/mem_pool.h index 46d044dc7..0a2e86b6d 100644 --- a/src/libutil/mem_pool.h +++ b/src/libutil/mem_pool.h @@ -46,7 +46,7 @@ struct f_str_s; #define MEMPOOL_TAG_LEN 20 #define MEMPOOL_UID_LEN 20 -#define MEM_ALIGNMENT sizeof (guint64) +#define MIN_MEM_ALIGNMENT sizeof (guint64) #define align_ptr(p, a) \ (guint8 *) (((uintptr_t) (p) + ((uintptr_t) a - 1)) & ~((uintptr_t) a - 1)) @@ -158,7 +158,7 @@ rspamd_mempool_t * rspamd_mempool_new_ (gsize size, const gchar *tag, const gcha * @return pointer to allocated object */ void * rspamd_mempool_alloc (rspamd_mempool_t * pool, gsize size) - RSPAMD_ATTR_ALLOC_SIZE(2) RSPAMD_ATTR_ALLOC_ALIGN(MEM_ALIGNMENT) RSPAMD_ATTR_RETURNS_NONNUL; + RSPAMD_ATTR_ALLOC_SIZE(2) RSPAMD_ATTR_ALLOC_ALIGN(MIN_MEM_ALIGNMENT) RSPAMD_ATTR_RETURNS_NONNUL; /** * Get memory from temporary pool @@ -175,7 +175,7 @@ void * rspamd_mempool_alloc_tmp (rspamd_mempool_t * pool, gsize size) RSPAMD_ATT * @return pointer to allocated object */ void * rspamd_mempool_alloc0 (rspamd_mempool_t * pool, gsize size) - RSPAMD_ATTR_ALLOC_SIZE(2) RSPAMD_ATTR_ALLOC_ALIGN(MEM_ALIGNMENT) RSPAMD_ATTR_RETURNS_NONNUL; + RSPAMD_ATTR_ALLOC_SIZE(2) RSPAMD_ATTR_ALLOC_ALIGN(MIN_MEM_ALIGNMENT) RSPAMD_ATTR_RETURNS_NONNUL; /** * Get memory and set it to zero @@ -197,7 +197,7 @@ void rspamd_mempool_cleanup_tmp (rspamd_mempool_t * pool); * @return pointer to newly created string that is copy of src */ gchar * rspamd_mempool_strdup (rspamd_mempool_t * pool, const gchar *src) - RSPAMD_ATTR_ALLOC_ALIGN(MEM_ALIGNMENT); + RSPAMD_ATTR_ALLOC_ALIGN(MIN_MEM_ALIGNMENT); /** * Make a copy of fixed string in pool as null terminated string @@ -206,7 +206,7 @@ gchar * rspamd_mempool_strdup (rspamd_mempool_t * pool, const gchar *src) * @return pointer to newly created string that is copy of src */ gchar * rspamd_mempool_fstrdup (rspamd_mempool_t * pool, - const struct f_str_s *src) RSPAMD_ATTR_ALLOC_ALIGN(MEM_ALIGNMENT); + const struct f_str_s *src) RSPAMD_ATTR_ALLOC_ALIGN(MIN_MEM_ALIGNMENT); struct f_str_tok; @@ -217,7 +217,7 @@ struct f_str_tok; * @return pointer to newly created string that is copy of src */ gchar * rspamd_mempool_ftokdup (rspamd_mempool_t *pool, - const struct f_str_tok *src) RSPAMD_ATTR_ALLOC_ALIGN(MEM_ALIGNMENT); + const struct f_str_tok *src) RSPAMD_ATTR_ALLOC_ALIGN(MIN_MEM_ALIGNMENT); /** * Allocate piece of shared memory @@ -225,9 +225,9 @@ gchar * rspamd_mempool_ftokdup (rspamd_mempool_t *pool, * @param size bytes to allocate */ void * rspamd_mempool_alloc_shared (rspamd_mempool_t * pool, gsize size) - RSPAMD_ATTR_ALLOC_SIZE(2) RSPAMD_ATTR_ALLOC_ALIGN(MEM_ALIGNMENT) RSPAMD_ATTR_RETURNS_NONNUL; + RSPAMD_ATTR_ALLOC_SIZE(2) RSPAMD_ATTR_ALLOC_ALIGN(MIN_MEM_ALIGNMENT) RSPAMD_ATTR_RETURNS_NONNUL; void * rspamd_mempool_alloc0_shared (rspamd_mempool_t *pool, gsize size) - RSPAMD_ATTR_ALLOC_SIZE(2) RSPAMD_ATTR_ALLOC_ALIGN(MEM_ALIGNMENT) RSPAMD_ATTR_RETURNS_NONNUL; + RSPAMD_ATTR_ALLOC_SIZE(2) RSPAMD_ATTR_ALLOC_ALIGN(MIN_MEM_ALIGNMENT) RSPAMD_ATTR_RETURNS_NONNUL; /** * Add destructor callback to pool * @param pool memory pool object |