Skip to content

Commit 6164668

Browse files
authored
fix thread-safe problem (#96)
1 parent 75b56b7 commit 6164668

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ bool GatewayNodeInfoImpl::tryAddNodeInfo(INodeInfo::Ptr const& info)
9999
// update the meta
100100
if (meta != existedNodeInfo->meta())
101101
{
102+
bcos::WriteGuard l(x_nodeList);
102103
existedNodeInfo->setMeta(meta);
103104
GATEWAY_LOG(INFO) << LOG_DESC("tryAddNodeInfo, update the meta, updated nodeInfo")
104105
<< printNodeInfo(existedNodeInfo);
@@ -107,6 +108,7 @@ bool GatewayNodeInfoImpl::tryAddNodeInfo(INodeInfo::Ptr const& info)
107108
auto components = info->copiedComponents();
108109
if (components != existedNodeInfo->copiedComponents())
109110
{
111+
bcos::WriteGuard l(x_nodeList);
110112
existedNodeInfo->setComponents(
111113
std::set<std::string>(components.begin(), components.end()));
112114
GATEWAY_LOG(INFO) << LOG_DESC("tryAddNodeInfo, update the components, updated nodeInfo")
@@ -260,6 +262,7 @@ void GatewayNodeInfoImpl::unRegisterTopic(bcos::bytes const& nodeID, std::string
260262

261263
void GatewayNodeInfoImpl::encode(bcos::bytes& data) const
262264
{
265+
bcos::ReadGuard l(x_nodeList);
263266
encodePBObject(data, m_rawGatewayInfo);
264267
}
265268

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ void GatewayRouterManager::onReceiveRequestNodeStatusMsg(
163163
}
164164
ROUTER_MGR_LOG(TRACE) << LOG_DESC(
165165
"onReceiveRequestNodeStatusMsg: response the latest nodeStatus")
166-
<< LOG_KV("node", printP2PIDElegantly(from));
166+
<< LOG_KV("to", printP2PIDElegantly(from));
167167
m_service->asyncSendMessageByP2PNodeID(
168168
(uint16_t)GatewayPacketType::ResponseNodeStatus, from, nodeStatusData);
169169
}

0 commit comments

Comments
 (0)