]> git.ipfire.org Git - thirdparty/rspamd.git/commitdiff
Test for atomic ops.
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Mon, 23 Nov 2015 09:10:12 +0000 (09:10 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Mon, 23 Nov 2015 09:10:12 +0000 (09:10 +0000)
CMakeLists.txt
src/libutil/ref.h
src/libutil/upstream.c

index c5e7625677ca38ce6da381f5625df7829e445b81..01d7d940bf8efd5c9676f2a6dfa4abb909722388 100644 (file)
@@ -146,6 +146,7 @@ INCLUDE(CheckIncludeFiles)
 INCLUDE(CheckFunctionExists)
 INCLUDE(CheckSymbolExists)
 INCLUDE(CheckCSourceCompiles)
+INCLUDE(CheckCSourceRuns)
 INCLUDE(CheckLibraryExists)
 INCLUDE(CheckCCompilerFlag)
 INCLUDE(CMakeParseArguments)
@@ -921,6 +922,16 @@ CHECK_C_SOURCE_COMPILES ("#include <sys/types.h>
                                                  }" HAVE_ASM_PAUSE)
 ENDIF(NOT CMAKE_SYSTEM_NAME STREQUAL "SunOS")
 
+CHECK_C_SOURCE_RUNS("
+int main(int argc, char **argv) {
+        int a = 0;
+        if (__sync_bool_compare_and_swap(&a, 0, 1)) {
+                return 0;
+        }
+        return -1;
+}
+" HAVE_ATOMIC_BUILTINS)
+
 # Check queue.h compatibility
 IF(NOT HAVE_COMPATIBLE_QUEUE_H)
        INCLUDE_DIRECTORIES(compat)
@@ -1038,6 +1049,7 @@ ADD_SUBDIRECTORY(utils)
 
 
 CONFIGURE_FILE(config.h.in src/config.h)
+ADD_DEFINITIONS("HAVE_CONFIG_H")
 
 ##################### INSTALLATION ##########################################
 
index 8caab5c8f30b2cf8b905b0ab2c60319bf5f391ac..18e2c390316e10bb3483d1149a9c8e7bf7ae1d9a 100644 (file)
@@ -23,6 +23,9 @@
 #ifndef REF_H_
 #define REF_H_
 
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
 /**
  * @file ref.h
  * A set of macros to handle refcounts
index 63680444ede9bbefb775306f10077e650f268d98..5b843451f28fc10258bbfcb9c096a968a912633a 100644 (file)
@@ -802,6 +802,7 @@ rspamd_upstream_reresolve (struct upstream_ctx *ctx)
 
        while (cur) {
                up = cur->data;
+               REF_RETAIN (up);
 
                if (up->name[0] != '/') {
                        if (rdns_make_request_full (ctx->res,
@@ -829,6 +830,7 @@ rspamd_upstream_reresolve (struct upstream_ctx *ctx)
                        }
                }
 
+               REF_RELEASE (up);
                cur = g_list_next (cur);
        }
 }