Skip to content

Commit

Permalink
fix gateway exist coredump
Browse files Browse the repository at this point in the history
  • Loading branch information
cyjseagull committed Nov 12, 2024
1 parent 19ccb82 commit 229e31c
Show file tree
Hide file tree
Showing 8 changed files with 49 additions and 43 deletions.
36 changes: 26 additions & 10 deletions cpp/cmake/CompilerSettings.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ if (("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU") OR ("${CMAKE_CXX_COMPILER_ID}" MA
# set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE "/usr/bin/time")
# set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK "/usr/bin/time")
# Use ISO C++17 standard language.
set(CMAKE_CXX_FLAGS "-pthread -fPIC -fexceptions")
# set(CMAKE_CXX_VISIBILITY_PRESET hidden)
# Enables all the warnings about constructions that some users consider questionable,
# and that are easy to avoid. Also enable some extra warning flags that are not
Expand Down Expand Up @@ -75,11 +74,16 @@ if (("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU") OR ("${CMAKE_CXX_COMPILER_ID}" MA

option(USE_LD_GOLD "Use GNU gold linker" ON)
if (USE_LD_GOLD)
execute_process(COMMAND ${CMAKE_C_COMPILER} -fuse-ld=gold -Wl,--version ERROR_QUIET OUTPUT_VARIABLE LD_VERSION)
if ("${LD_VERSION}" MATCHES "GNU gold")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fuse-ld=gold")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -fuse-ld=gold")
endif ()
if("${LINKER}" MATCHES "gold")
execute_process(COMMAND ${CMAKE_C_COMPILER} -fuse-ld=gold -Wl,--version ERROR_QUIET OUTPUT_VARIABLE LD_VERSION)
if("${LD_VERSION}" MATCHES "GNU gold")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fuse-ld=gold")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -fuse-ld=gold")
endif()
elseif("${LINKER}" MATCHES "mold")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fuse-ld=mold")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -fuse-ld=mold")
endif()
endif ()

# Additional GCC-specific compiler settings.
Expand All @@ -92,14 +96,26 @@ if (("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU") OR ("${CMAKE_CXX_COMPILER_ID}" MA
message(FATAL_ERROR "${PROJECT_NAME} requires g++ ${GCC_MIN_VERSION} or greater. Current is ${GCC_VERSION}")
endif ()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${MARCH_TYPE}")
set(CMAKE_C_FLAGS "-std=c99 ${CMAKE_C_FLAGS} ${MARCH_TYPE}")
set(CMAKE_C_FLAGS "-std=c99 -fexceptions ${CMAKE_C_FLAGS} ${MARCH_TYPE}")

# Strong stack protection was only added in GCC 4.9.
# Use it if we have the option to do so.
# See https://lwn.net/Articles/584225/
if (GCC_VERSION VERSION_GREATER 4.9 OR GCC_VERSION VERSION_EQUAL 4.9)
add_compile_options(-fstack-protector-strong)
add_compile_options(-fstack-protector)
add_compile_options(-fstack-protector-strong)
add_compile_options(-fstack-protector)

add_compile_options(-fPIC)
add_compile_options(-Wno-error=nonnull)
add_compile_options(-foptimize-sibling-calls)
add_compile_options(-Wno-stringop-overflow)
add_compile_options(-Wno-restrict)
add_compile_options(-Wno-error=format-truncation)

if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 11.0)
add_compile_options(-Wno-stringop-overread)
add_compile_options(-Wno-maybe-uninitialized)
add_compile_options(-Wno-array-bounds)
add_compile_options(-Wno-aggressive-loop-optimizations)
endif()
# Additional Clang-specific compiler settings.
elseif ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
Expand Down
28 changes: 0 additions & 28 deletions cpp/wedpr-helper/libhelper/CommandHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,31 +81,3 @@ CommandLineParam ppc::initCommandLine(int argc, const char* argv[])
}
return ppc::CommandLineParam{configPath};
}

void ppc::initAppCommandLine(int argc, char* argv[])
{
boost::program_options::options_description main_options("Usage of PPC");
main_options.add_options()("help,h", "print help information")("version,v", "version of PPC");
boost::program_options::variables_map vm;
try
{
boost::program_options::store(
boost::program_options::parse_command_line(argc, argv, main_options), vm);
}
catch (...)
{
printVersion();
}
/// help information
if (vm.count("help") || vm.count("h"))
{
std::cout << main_options << std::endl;
exit(0);
}
/// version information
if (vm.count("version") || vm.count("v"))
{
printVersion();
exit(0);
}
}
1 change: 0 additions & 1 deletion cpp/wedpr-helper/libhelper/CommandHelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,4 @@ struct CommandLineParam
};
void printVersion();
CommandLineParam initCommandLine(int argc, const char* argv[]);
void initAppCommandLine(int argc, char* argv[]);
} // namespace ppc
2 changes: 1 addition & 1 deletion cpp/wedpr-main/common/NodeStarter.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ namespace ppc::node
{
template <typename T>
int startProgram(
int argc, const char* argv[], std::string const& binaryName, std::shared_ptr<T>& starter)
int argc, const char* argv[], std::string const& binaryName, std::shared_ptr<T> starter)
{
/// set LC_ALL
setDefaultOrCLocale();
Expand Down
2 changes: 1 addition & 1 deletion cpp/wedpr-main/gateway/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ include_directories(${CMAKE_SOURCE_DIR})
aux_source_directory(./ SRC_LIST)
add_executable(${GATEWAY_BINARY_NAME} ${SRC_LIST})

target_link_libraries(${GATEWAY_BINARY_NAME} ${GATEWAY_TARGET} ${STORAGE_TARGET} ${SERVICE_CLIENT_TARGET} ${SERVICE_SERVER_TARGET} ${HELPER_TARGET})
target_link_libraries(${GATEWAY_BINARY_NAME} ${GATEWAY_TARGET} ${SERVICE_CLIENT_TARGET} ${SERVICE_SERVER_TARGET} ${HELPER_TARGET})
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,10 @@ void GatewayRouterManager::start()
return;
}
m_running = true;
m_timer->start();
if (m_timer)
{
m_timer->start();
}
ROUTER_MGR_LOG(INFO) << LOG_DESC("start GatewayRouterManager success");
}

Expand All @@ -76,7 +79,10 @@ void GatewayRouterManager::stop()
return;
}
m_running = false;
m_timer->stop();
if (m_timer)
{
m_timer->stop();
}
ROUTER_MGR_LOG(INFO) << LOG_DESC("stop GatewayRouterManager success");
}

Expand Down
11 changes: 11 additions & 0 deletions cpp/wedpr-transport/ppc-gateway/ppc-gateway/p2p/Service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,17 @@ Service::Service(std::string const& _nodeID, RouterTableFactory::Ptr const& _rou
boost::bind(&Service::onP2PDisconnect, this, boost::placeholders::_1));
}

void Service::stop()
{
SERVICE_LOG(INFO) << LOG_DESC("stop service");
// stop the timerFactory
if (m_timerFactory)
{
m_timerFactory.reset();
}
WsService::stop();
}

void Service::onP2PConnect(WsSession::Ptr _session)
{
SERVICE_LOG(INFO) << LOG_DESC("Receive new p2p connection")
Expand Down
2 changes: 2 additions & 0 deletions cpp/wedpr-transport/ppc-gateway/ppc-gateway/p2p/Service.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ class Service : public bcos::boostssl::ws::WsService
m_deleteSessionHandlers.emplace_back(_handler);
}

void stop() override;

protected:
void onRecvMessage(bcos::boostssl::MessageFace::Ptr _msg,
bcos::boostssl::ws::WsSession::Ptr _session) override;
Expand Down

0 comments on commit 229e31c

Please sign in to comment.