+cmake_minimum_required(VERSION 3.28 FATAL_ERROR)
+
# project: definitions
project(pingcheck)
-set(VERSION 0.7)
-set(VERSION_REVISION 1)
+set(VERSION 0.8)
+set(VERSION_REVISION 0)
set(TARGET ${PROJECT_NAME})
# cmake: build options
set(CMAKE_COLOR_MAKEFILE ON)
-cmake_minimum_required(VERSION 2.6 FATAL_ERROR)
# compiler: add definitions and arguments to the compiler
add_definitions(
set(Boost_USE_STATIC_LIBS OFF)
set(Boost_USE_MULTITHREADED OFF)
set(Boost_USE_STATIC_RUNTIME OFF)
+
find_package(Boost 1.44 COMPONENTS filesystem program_options system serialization date_time REQUIRED)
-include_directories(${Boost_INCLUDE_DIRS})
-link_directories(${Boost_LIBRARY_DIRS})
# package: boost-custom
include_directories(${CMAKE_SOURCE_DIR}/lib/boost-custom)
# linker: link the program against the libraries
target_link_libraries(
${TARGET}
- ${Boost_LIBRARIES}
+ Boost::filesystem
+ Boost::program_options
+ Boost::system
+ Boost::serialization
+ Boost::date_time
${I2NCOMMON_LIBRARIES}
pthread
)
target_link_libraries(
feed_packet_data
lib_for_tools
- ${Boost_LIBRARIES}
+ Boost::filesystem
+ Boost::program_options
+ Boost::system
+ Boost::serialization
+ Boost::date_time
${I2NCOMMON_LIBRARIES}
)
# no install! install(TARGETS feed_packet_data DESTINATION bin)
#include <fstream>
#include <logfunc.hpp>
#include <filefunc.hxx> // I2n::file_exists
+#include <tmpfstream.hpp>
#include <boost/foreach.hpp>
#include <boost/bind.hpp>
#include <boost/asio/placeholders.hpp>
std::string cache_save_time_str = boost::posix_time::to_iso_string(
boost::posix_time::second_clock::universal_time() );
- std::ofstream ofs( CacheFile.c_str() );
+ I2n::tmpofcopystream ofs( CacheFile.c_str() );
boost::archive::xml_oarchive oa(ofs);
oa & BOOST_SERIALIZATION_NVP(IpCache);
oa & BOOST_SERIALIZATION_NVP(CnameCache);
std::ifstream ifs( CacheFile.c_str() );
boost::archive::xml_iarchive ia(ifs);
+ ip_map_type new_IpCache;
+ cname_map_type new_CnameCache;
std::string cache_save_time_str;
- ia & BOOST_SERIALIZATION_NVP(IpCache);
- ia & BOOST_SERIALIZATION_NVP(CnameCache);
+ ia & BOOST_SERIALIZATION_NVP(new_IpCache);
+ ia & BOOST_SERIALIZATION_NVP(new_CnameCache);
ia & BOOST_SERIALIZATION_NVP(cache_save_time_str);
- boost::posix_time::ptime cache_save_time
+ const boost::posix_time::ptime cache_save_time
= boost::posix_time::from_iso_string(cache_save_time_str);
GlobalLogger.info() << "DnsCache: loaded from file " << CacheFile;
+ // atomic switch over
+ IpCache.swap(new_IpCache);
+ CnameCache.swap(new_CnameCache);
+
check_timestamps(cache_save_time);
}
catch (boost::archive::archive_exception &exc)
# compiler: creates the binaries
add_executable(test_linkstatus
- test_linkstatus
+ test_linkstatus.cpp
${CMAKE_SOURCE_DIR}/src/boost_assert_handler.cpp
${CMAKE_SOURCE_DIR}/src/link/linkstatus.cpp
${CMAKE_SOURCE_DIR}/src/dns/hostaddress.cpp
target_link_libraries(
test_linkstatus
${I2NCOMMON_LIBRARIES}
- ${Boost_LIBRARIES}
+ Boost::unit_test_framework
+ Boost::system
+ Boost::program_options
+ Boost::date_time
+ Boost::serialization
pthread
)