Migrate to CAF 0.18

This commit is contained in:
Dominik Charousset 2020-12-07 14:56:19 +01:00
parent 6323b0a8c2
commit cf2b5f7e05
4 changed files with 41 additions and 24 deletions

View file

@ -1,6 +1,6 @@
# When changing the minimum version here, also adapt
# auxil/zeek-aux/plugin-support/skeleton/CMakeLists.txt
cmake_minimum_required(VERSION 3.5 FATAL_ERROR)
cmake_minimum_required(VERSION 3.5...3.18 FATAL_ERROR)
project(Zeek C CXX)
@ -289,18 +289,33 @@ if ( PYTHON_VERSION_STRING VERSION_LESS ${ZEEK_PYTHON_MIN} )
message(FATAL_ERROR "Python ${ZEEK_PYTHON_MIN} or greater is required.")
endif ()
if ( CAF_ROOT_DIR )
find_package(CAF COMPONENTS core io openssl REQUIRED)
if ( CAF_ROOT OR BROKER_ROOT_DIR )
# TODO: drop < 3.12 compatibility check when raising the minimum CMake version
if ( CAF_ROOT AND CMAKE_VERSION VERSION_LESS 3.12 )
find_package(CAF ${CAF_VERSION_MIN_REQUIRED} REQUIRED CONFIG
COMPONENTS openssl test io core
PATHS "${CAF_ROOT}")
else ()
find_package(CAF ${CAF_VERSION_MIN_REQUIRED} REQUIRED CONFIG
COMPONENTS openssl test io core)
endif ()
message(STATUS "Using system CAF version ${CAF_VERSION}")
# TODO: drop these legacy variables and simply use the targets consistently
set(CAF_LIBRARIES CAF::core CAF::io CAF::openssl CACHE INTERNAL "")
set(caf_dirs "")
foreach (caf_lib IN LISTS CAF_LIBRARIES ITEMS CAF::test)
get_target_property(dirs ${caf_lib} INTERFACE_INCLUDE_DIRECTORIES)
list(APPEND caf_dirs ${dirs})
endforeach ()
list(REMOVE_DUPLICATES caf_dirs)
list(GET caf_dirs 0 caf_dir)
set(CAF_INCLUDE_DIRS "${caf_dirs}" CACHE INTERNAL "")
endif ()
add_subdirectory(auxil/paraglob)
set(zeekdeps ${zeekdeps} paraglob)
if ( BROKER_ROOT_DIR )
# Avoid calling find_package(CAF) twice.
if ( NOT CAF_ROOT_DIR )
find_package(CAF COMPONENTS core io openssl REQUIRED)
endif ()
find_package(Broker REQUIRED)
set(zeekdeps ${zeekdeps} ${BROKER_LIBRARY})
set(broker_includes ${BROKER_INCLUDE_DIR})
@ -455,8 +470,8 @@ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/zeek-config.h.in
include_directories(${CMAKE_CURRENT_BINARY_DIR})
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/zeek-config.h DESTINATION include/zeek)
if ( CAF_ROOT_DIR )
set(ZEEK_CONFIG_CAF_ROOT_DIR ${CAF_ROOT_DIR})
if ( CAF_ROOT )
set(ZEEK_CONFIG_CAF_ROOT ${CAF_ROOT_DIR})
else ()
set(ZEEK_CONFIG_CAF_ROOT_DIR ${ZEEK_ROOT_DIR})
endif ()

@ -1 +1 @@
Subproject commit 8899280694d8d5ad3aaa0a03cc99e4c3d3fd7887
Subproject commit 4f43a95824c700642bf466f6f41274fc4d1baebb

2
configure vendored
View file

@ -328,7 +328,7 @@ while [ $# -ne 0 ]; do
append_cache_entry BROKER_ROOT_DIR PATH $optarg
;;
--with-caf=*)
append_cache_entry CAF_ROOT_DIR PATH $optarg
append_cache_entry CAF_ROOT PATH $optarg
;;
--with-libkqueue=*)
append_cache_entry LIBKQUEUE_ROOT_DIR PATH $optarg

View file

@ -176,36 +176,36 @@ void Manager::InitPostScript()
auto scheduler_policy = get_option("Broker::scheduler_policy")->AsString()->CheckString();
if ( util::streq(scheduler_policy, "sharing") )
config.set("scheduler.policy", caf::atom("sharing"));
config.set("caf.scheduler.policy", "sharing");
else if ( util::streq(scheduler_policy, "stealing") )
config.set("scheduler.policy", caf::atom("stealing"));
config.set("caf.scheduler.policy", "stealing");
else
reporter->FatalError("Invalid Broker::scheduler_policy: %s", scheduler_policy);
auto max_threads_env = util::zeekenv("ZEEK_BROKER_MAX_THREADS");
if ( max_threads_env )
config.set("scheduler.max-threads", atoi(max_threads_env));
config.set("caf.scheduler.max-threads", atoi(max_threads_env));
else
config.set("scheduler.max-threads",
config.set("caf.scheduler.max-threads",
get_option("Broker::max_threads")->AsCount());
config.set("work-stealing.moderate-sleep-duration", caf::timespan(
config.set("caf.work-stealing.moderate-sleep-duration", caf::timespan(
static_cast<unsigned>(get_option("Broker::moderate_sleep")->AsInterval() * 1e9)));
config.set("work-stealing.relaxed-sleep-duration", caf::timespan(
config.set("caf.work-stealing.relaxed-sleep-duration", caf::timespan(
static_cast<unsigned>(get_option("Broker::relaxed_sleep")->AsInterval() * 1e9)));
config.set("work-stealing.aggressive-poll-attempts",
config.set("caf.work-stealing.aggressive-poll-attempts",
get_option("Broker::aggressive_polls")->AsCount());
config.set("work-stealing.moderate-poll-attempts",
config.set("caf.work-stealing.moderate-poll-attempts",
get_option("Broker::moderate_polls")->AsCount());
config.set("work-stealing.aggressive-steal-interval",
config.set("caf.work-stealing.aggressive-steal-interval",
get_option("Broker::aggressive_interval")->AsCount());
config.set("work-stealing.moderate-steal-interval",
config.set("caf.work-stealing.moderate-steal-interval",
get_option("Broker::moderate_interval")->AsCount());
config.set("work-stealing.relaxed-steal-interval",
config.set("caf.work-stealing.relaxed-steal-interval",
get_option("Broker::relaxed_interval")->AsCount());
auto cqs = get_option("Broker::congestion_queue_size")->AsCount();
@ -1487,7 +1487,7 @@ void Manager::ProcessError(broker::error err)
BifEnum::Broker::ErrorCode ec;
std::string msg;
if ( err.category() == caf::atom("broker") )
if ( err.category() == caf::type_id_v<broker::ec> )
{
static auto enum_type = id::find_type<EnumType>("Broker::ErrorCode");
@ -1504,7 +1504,9 @@ void Manager::ProcessError(broker::error err)
else
{
ec = BifEnum::Broker::ErrorCode::CAF_ERROR;
msg = util::fmt("[%s] %s", caf::to_string(err.category()).c_str(), caf::to_string(err.context()).c_str());
auto sv = caf::query_type_name(err.category());
std::string category{sv.begin(), sv.end()};
msg = util::fmt("[%s] %s", category.c_str(), caf::to_string(err.context()).c_str());
}
event_mgr.Enqueue(::Broker::error,