Skip to content

Commit 229e31c

Browse files
committed
fix gateway exist coredump
1 parent 19ccb82 commit 229e31c

File tree

8 files changed

+49
-43
lines changed

8 files changed

+49
-43
lines changed

cpp/cmake/CompilerSettings.cmake

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ if (("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU") OR ("${CMAKE_CXX_COMPILER_ID}" MA
1717
# set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE "/usr/bin/time")
1818
# set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK "/usr/bin/time")
1919
# Use ISO C++17 standard language.
20-
set(CMAKE_CXX_FLAGS "-pthread -fPIC -fexceptions")
2120
# set(CMAKE_CXX_VISIBILITY_PRESET hidden)
2221
# Enables all the warnings about constructions that some users consider questionable,
2322
# and that are easy to avoid. Also enable some extra warning flags that are not
@@ -75,11 +74,16 @@ if (("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU") OR ("${CMAKE_CXX_COMPILER_ID}" MA
7574

7675
option(USE_LD_GOLD "Use GNU gold linker" ON)
7776
if (USE_LD_GOLD)
78-
execute_process(COMMAND ${CMAKE_C_COMPILER} -fuse-ld=gold -Wl,--version ERROR_QUIET OUTPUT_VARIABLE LD_VERSION)
79-
if ("${LD_VERSION}" MATCHES "GNU gold")
80-
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fuse-ld=gold")
81-
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -fuse-ld=gold")
82-
endif ()
77+
if("${LINKER}" MATCHES "gold")
78+
execute_process(COMMAND ${CMAKE_C_COMPILER} -fuse-ld=gold -Wl,--version ERROR_QUIET OUTPUT_VARIABLE LD_VERSION)
79+
if("${LD_VERSION}" MATCHES "GNU gold")
80+
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fuse-ld=gold")
81+
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -fuse-ld=gold")
82+
endif()
83+
elseif("${LINKER}" MATCHES "mold")
84+
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fuse-ld=mold")
85+
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -fuse-ld=mold")
86+
endif()
8387
endif ()
8488

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

97101
# Strong stack protection was only added in GCC 4.9.
98102
# Use it if we have the option to do so.
99103
# See https://lwn.net/Articles/584225/
100-
if (GCC_VERSION VERSION_GREATER 4.9 OR GCC_VERSION VERSION_EQUAL 4.9)
101-
add_compile_options(-fstack-protector-strong)
102-
add_compile_options(-fstack-protector)
104+
add_compile_options(-fstack-protector-strong)
105+
add_compile_options(-fstack-protector)
106+
107+
add_compile_options(-fPIC)
108+
add_compile_options(-Wno-error=nonnull)
109+
add_compile_options(-foptimize-sibling-calls)
110+
add_compile_options(-Wno-stringop-overflow)
111+
add_compile_options(-Wno-restrict)
112+
add_compile_options(-Wno-error=format-truncation)
113+
114+
if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 11.0)
115+
add_compile_options(-Wno-stringop-overread)
116+
add_compile_options(-Wno-maybe-uninitialized)
117+
add_compile_options(-Wno-array-bounds)
118+
add_compile_options(-Wno-aggressive-loop-optimizations)
103119
endif()
104120
# Additional Clang-specific compiler settings.
105121
elseif ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")

cpp/wedpr-helper/libhelper/CommandHelper.cpp

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -81,31 +81,3 @@ CommandLineParam ppc::initCommandLine(int argc, const char* argv[])
8181
}
8282
return ppc::CommandLineParam{configPath};
8383
}
84-
85-
void ppc::initAppCommandLine(int argc, char* argv[])
86-
{
87-
boost::program_options::options_description main_options("Usage of PPC");
88-
main_options.add_options()("help,h", "print help information")("version,v", "version of PPC");
89-
boost::program_options::variables_map vm;
90-
try
91-
{
92-
boost::program_options::store(
93-
boost::program_options::parse_command_line(argc, argv, main_options), vm);
94-
}
95-
catch (...)
96-
{
97-
printVersion();
98-
}
99-
/// help information
100-
if (vm.count("help") || vm.count("h"))
101-
{
102-
std::cout << main_options << std::endl;
103-
exit(0);
104-
}
105-
/// version information
106-
if (vm.count("version") || vm.count("v"))
107-
{
108-
printVersion();
109-
exit(0);
110-
}
111-
}

cpp/wedpr-helper/libhelper/CommandHelper.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,4 @@ struct CommandLineParam
2929
};
3030
void printVersion();
3131
CommandLineParam initCommandLine(int argc, const char* argv[]);
32-
void initAppCommandLine(int argc, char* argv[]);
3332
} // namespace ppc

cpp/wedpr-main/common/NodeStarter.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ namespace ppc::node
2929
{
3030
template <typename T>
3131
int startProgram(
32-
int argc, const char* argv[], std::string const& binaryName, std::shared_ptr<T>& starter)
32+
int argc, const char* argv[], std::string const& binaryName, std::shared_ptr<T> starter)
3333
{
3434
/// set LC_ALL
3535
setDefaultOrCLocale();

cpp/wedpr-main/gateway/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ include_directories(${CMAKE_SOURCE_DIR})
44
aux_source_directory(./ SRC_LIST)
55
add_executable(${GATEWAY_BINARY_NAME} ${SRC_LIST})
66

7-
target_link_libraries(${GATEWAY_BINARY_NAME} ${GATEWAY_TARGET} ${STORAGE_TARGET} ${SERVICE_CLIENT_TARGET} ${SERVICE_SERVER_TARGET} ${HELPER_TARGET})
7+
target_link_libraries(${GATEWAY_BINARY_NAME} ${GATEWAY_TARGET} ${SERVICE_CLIENT_TARGET} ${SERVICE_SERVER_TARGET} ${HELPER_TARGET})

cpp/wedpr-transport/ppc-gateway/ppc-gateway/gateway/router/GatewayRouterManager.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,10 @@ void GatewayRouterManager::start()
6464
return;
6565
}
6666
m_running = true;
67-
m_timer->start();
67+
if (m_timer)
68+
{
69+
m_timer->start();
70+
}
6871
ROUTER_MGR_LOG(INFO) << LOG_DESC("start GatewayRouterManager success");
6972
}
7073

@@ -76,7 +79,10 @@ void GatewayRouterManager::stop()
7679
return;
7780
}
7881
m_running = false;
79-
m_timer->stop();
82+
if (m_timer)
83+
{
84+
m_timer->stop();
85+
}
8086
ROUTER_MGR_LOG(INFO) << LOG_DESC("stop GatewayRouterManager success");
8187
}
8288

cpp/wedpr-transport/ppc-gateway/ppc-gateway/p2p/Service.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,17 @@ Service::Service(std::string const& _nodeID, RouterTableFactory::Ptr const& _rou
4848
boost::bind(&Service::onP2PDisconnect, this, boost::placeholders::_1));
4949
}
5050

51+
void Service::stop()
52+
{
53+
SERVICE_LOG(INFO) << LOG_DESC("stop service");
54+
// stop the timerFactory
55+
if (m_timerFactory)
56+
{
57+
m_timerFactory.reset();
58+
}
59+
WsService::stop();
60+
}
61+
5162
void Service::onP2PConnect(WsSession::Ptr _session)
5263
{
5364
SERVICE_LOG(INFO) << LOG_DESC("Receive new p2p connection")

cpp/wedpr-transport/ppc-gateway/ppc-gateway/p2p/Service.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@ class Service : public bcos::boostssl::ws::WsService
8181
m_deleteSessionHandlers.emplace_back(_handler);
8282
}
8383

84+
void stop() override;
85+
8486
protected:
8587
void onRecvMessage(bcos::boostssl::MessageFace::Ptr _msg,
8688
bcos::boostssl::ws::WsSession::Ptr _session) override;

0 commit comments

Comments
 (0)