From 4769f66eea406a4dcab97fd50b9282705fb6c643 Mon Sep 17 00:00:00 2001 From: Taha Afzal Date: Wed, 19 Apr 2023 17:16:54 +0000 Subject: [PATCH] Adding some logs to SharedMemory and SharedList --- CMakeLists.txt | 1 + src/lib/orderman/gateways/CCAPIExecutionGateway.cpp | 1 + src/lib/orderman/gateways/ExecutionGatewayFactory.cpp | 1 + src/lib/utils/SharedList.h | 10 ++++++++-- src/lib/utils/SharedMemory.cpp | 8 ++++++++ 5 files changed, 19 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3ac85f708..6d795590a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -85,6 +85,7 @@ else() # Enable ccapi exchanges/services add_compile_definitions(CCAPI_ENABLE_SERVICE_MARKET_DATA) + add_compile_definitions(CCAPI_ENABLE_SERVICE_EXECUTION_MANAGEMENT) add_compile_definitions(CCAPI_ENABLE_EXCHANGE_DERIBIT) add_compile_definitions(CCAPI_ENABLE_EXCHANGE_FTX) add_compile_definitions(CCAPI_ENABLE_EXCHANGE_BINANCE) diff --git a/src/lib/orderman/gateways/CCAPIExecutionGateway.cpp b/src/lib/orderman/gateways/CCAPIExecutionGateway.cpp index a6e7e2ee8..172125eb9 100644 --- a/src/lib/orderman/gateways/CCAPIExecutionGateway.cpp +++ b/src/lib/orderman/gateways/CCAPIExecutionGateway.cpp @@ -26,6 +26,7 @@ #include "lib/utils/bts_assert.h" #include "lib/utils/datetime.h" //#include "lib/utils/helper_macros.h" +#include "lib/orderman/ccapi/ICCAPIOrderMux.h" #include "lib/api/service_helpers/AdminServiceUtils.h" #include "lib/config/config.h" diff --git a/src/lib/orderman/gateways/ExecutionGatewayFactory.cpp b/src/lib/orderman/gateways/ExecutionGatewayFactory.cpp index a72c410c5..2bfb64661 100644 --- a/src/lib/orderman/gateways/ExecutionGatewayFactory.cpp +++ b/src/lib/orderman/gateways/ExecutionGatewayFactory.cpp @@ -36,6 +36,7 @@ std::unique_ptr ExecutionGatewayFactory::create_gateway( return std::make_unique(conn, pl, o); } else if (conn.venue() == bts::api::VENUE_DERIBIT) return std::make_unique(o); + //return std::make_unique(o); return std::make_unique(o); } diff --git a/src/lib/utils/SharedList.h b/src/lib/utils/SharedList.h index 4175397e1..7cb2c0c3c 100644 --- a/src/lib/utils/SharedList.h +++ b/src/lib/utils/SharedList.h @@ -12,8 +12,8 @@ #include "lib/os/os.h" #include -#include #include +#include #include #include #include @@ -62,6 +62,10 @@ template class SharedList { _segments_mapped(0), _current_region(nullptr), _current_segment_header(nullptr), _header(nullptr), _shm(create_low_level_shared_memory(should_share(shared))) { + LOG(md, Info, + "SharedList::cons name: {} initial_size_kb: {} block_size_kb: {} " + "shared: {}", + name, initial_size_kb, block_size_kb, shared); if (shared) delete_segments(_name); @@ -156,7 +160,9 @@ template class SharedList { std::string(segment_name), size); _current_region = _shm->create(segment_name, size).address; - bts_assert(_current_region); + bts_assert_msg( + _current_region, + "expand failed for segment: " + std::string(segment_name)); _current_region_size = size; _current_offset = 0; // Start each segment with a SegmentHeader diff --git a/src/lib/utils/SharedMemory.cpp b/src/lib/utils/SharedMemory.cpp index 4de8f0f68..88a7c0173 100644 --- a/src/lib/utils/SharedMemory.cpp +++ b/src/lib/utils/SharedMemory.cpp @@ -83,7 +83,15 @@ struct BoostLowLevelSharedMemoryImpl { block.truncate(size); add_region(std::move(block)); return make_segment(size, _mappings.back().second.get_address()); + } catch (const boost::interprocess::interprocess_exception &ex) { + LOG(md, Error, + "SharedMemory::create interprocess_exception what: {} error_code: " + "{} native_error: {}", + std::string(ex.what()), ex.get_error_code(), + ex.get_native_error()); + return make_segment(0, nullptr); } catch (...) { + LOG(md, Error, "SharedMemory::create unknown exception"); return make_segment(0, nullptr); } }