From ab72e9d492987ff27a480bdc5011b447c2ada520 Mon Sep 17 00:00:00 2001 From: Duncan Bellamy Date: Mon, 24 May 2021 14:17:34 +0100 Subject: [PATCH] [Minor] change headers for zstd depending on bundled or system used follow on patch from #3764 --- CMakeLists.txt | 1 + src/client/rspamdclient.c | 7 ++++++- src/libserver/cfg_utils.c | 8 ++++++-- src/libserver/maps/map.c | 7 ++++++- src/libserver/protocol.c | 7 ++++++- src/libserver/task.c | 9 +++++++-- src/lua/lua_compress.c | 12 +++++++++--- src/rspamd_proxy.c | 7 ++++++- 8 files changed, 47 insertions(+), 11 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a110f14f7..b46de3f4d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -633,6 +633,7 @@ IF(SYSTEM_ZSTD MATCHES "OFF") ELSE() ProcessPackage(LIBZSTD LIBRARY zstd INCLUDE zstd.h ROOT ${LIBZSTD_ROOT_DIR} MODULES zstd) + ADD_DEFINITIONS(-DSYS_ZSTD) ENDIF() IF(ENABLE_SNOWBALL MATCHES "ON") ADD_SUBDIRECTORY(contrib/snowball) diff --git a/src/client/rspamdclient.c b/src/client/rspamdclient.c index 9a2e7f88d..f9f337864 100644 --- a/src/client/rspamdclient.c +++ b/src/client/rspamdclient.c @@ -19,7 +19,12 @@ #include "libserver/http/http_private.h" #include "libserver/protocol_internal.h" #include "unix-std.h" -#include "contrib/zstd/zstd.h" + +#ifdef SYS_ZSTD +# include "zstd.h" +#else +# include "contrib/zstd/zstd.h" +#endif #ifdef HAVE_FETCH_H #include diff --git a/src/libserver/cfg_utils.c b/src/libserver/cfg_utils.c index 98e409d0f..d846153b8 100644 --- a/src/libserver/cfg_utils.c +++ b/src/libserver/cfg_utils.c @@ -36,8 +36,12 @@ #include "contrib/libottery/ottery.h" #include "contrib/fastutf8/fastutf8.h" -#define ZSTD_STATIC_LINKING_ONLY -#include "contrib/zstd/zstd.h" +#ifdef SYS_ZSTD +# include "zstd.h" +#else +# define ZSTD_STATIC_LINKING_ONLY +# include "contrib/zstd/zstd.h" +#endif #ifdef HAVE_OPENSSL #include diff --git a/src/libserver/maps/map.c b/src/libserver/maps/map.c index bc53ca538..f324f9d70 100644 --- a/src/libserver/maps/map.c +++ b/src/libserver/maps/map.c @@ -23,10 +23,15 @@ #include "libserver/http/http_connection.h" #include "libserver/http/http_private.h" #include "rspamd.h" -#include "contrib/zstd/zstd.h" #include "contrib/libev/ev.h" #include "contrib/uthash/utlist.h" +#ifdef SYS_ZSTD +# include "zstd.h" +#else +# include "contrib/zstd/zstd.h" +#endif + #undef MAP_DEBUG_REFS #ifdef MAP_DEBUG_REFS #define MAP_RETAIN(x, t) do { \ diff --git a/src/libserver/protocol.c b/src/libserver/protocol.c index e7f4dbd50..6e97068a6 100644 --- a/src/libserver/protocol.c +++ b/src/libserver/protocol.c @@ -21,7 +21,6 @@ #include "worker_private.h" #include "libserver/cfg_file_private.h" #include "libmime/scan_result_private.h" -#include "contrib/zstd/zstd.h" #include "lua/lua_common.h" #include "unix-std.h" #include "protocol_internal.h" @@ -30,6 +29,12 @@ #include "task.h" #include +#ifdef SYS_ZSTD +# include "zstd.h" +#else +# include "contrib/zstd/zstd.h" +#endif + INIT_LOG_MODULE(protocol) #define msg_err_protocol(...) rspamd_default_log_function (G_LOG_LEVEL_CRITICAL, \ diff --git a/src/libserver/task.c b/src/libserver/task.c index 407f2c4d4..aae374c21 100644 --- a/src/libserver/task.c +++ b/src/libserver/task.c @@ -25,7 +25,6 @@ #include "stat_api.h" #include "unix-std.h" #include "utlist.h" -#include "contrib/zstd/zstd.h" #include "libserver/mempool_vars_internal.h" #include "libserver/cfg_file_private.h" #include "libmime/lang_detection.h" @@ -41,6 +40,12 @@ #include +#ifdef SYS_ZSTD +# include "zstd.h" +#else +# include "contrib/zstd/zstd.h" +#endif + __KHASH_IMPL (rspamd_req_headers_hash, static inline, rspamd_ftok_t *, struct rspamd_request_header_chain *, 1, rspamd_ftok_icase_hash, rspamd_ftok_icase_equal) @@ -1981,4 +1986,4 @@ rspamd_worker_guard_handler (EV_P_ ev_io *w, int revents) return; } } -} \ No newline at end of file +} diff --git a/src/lua/lua_compress.c b/src/lua/lua_compress.c index 5bebd0e0d..599a796e0 100644 --- a/src/lua/lua_compress.c +++ b/src/lua/lua_compress.c @@ -16,10 +16,16 @@ #include "lua_common.h" #include "unix-std.h" -#include "contrib/zstd/zstd.h" -#include "contrib/zstd/error_public.h" #include +#ifdef SYS_ZSTD +# include "zstd.h" +# include "zstd_errors.h" +#else +# include "contrib/zstd/zstd.h" +# include "contrib/zstd/error_public.h" +#endif + /*** * @module rspamd_compress * This module contains compression/decompression routines (zstd and zlib currently) @@ -614,4 +620,4 @@ luaopen_compress (lua_State *L) lua_pop (L, 2); rspamd_lua_add_preload (L, "rspamd_zstd", lua_load_zstd); -} \ No newline at end of file +} diff --git a/src/rspamd_proxy.c b/src/rspamd_proxy.c index f5bc5f68e..267760c03 100644 --- a/src/rspamd_proxy.c +++ b/src/rspamd_proxy.c @@ -36,7 +36,6 @@ #include "libserver/milter.h" #include "libserver/milter_internal.h" #include "libmime/lang_detection.h" -#include "contrib/zstd/zstd.h" #include @@ -44,6 +43,12 @@ #include /* for TCP_NODELAY */ #endif +#ifdef SYS_ZSTD +# include "zstd.h" +#else +# include "contrib/zstd/zstd.h" +#endif + /* Rotate keys each minute by default */ #define DEFAULT_ROTATION_TIME 60.0 #define DEFAULT_RETRIES 5 -- 2.39.5