修复:UDP 接收队列数据竞争导致 SIGSEGV 崩溃
pushMsgToQueue 在监听线程向各接收队列 push 时无锁, 而 clearMsgQueue/popMsgFormQueue 在 MOOS 主线程持锁 pop, 并发操作同一 deque 造成堆内存损坏,收到 140 CCU UDP 消息后崩溃。 为 6 处 push 补上与 clear/pop 对应的互斥锁 (m_mutexCcuState/CcuSetParm/DisHighVolBus/DisHighAVolBus/ DisHighBVolBus/DisLowBus),修复数据竞争。
This commit is contained in:
@@ -178,6 +178,7 @@ bool udpComm::pushMsgToQueue(unsigned char *m)
|
||||
if(m_qReceiveCcuStateBuffer.size()<QUENUE_SIZE)
|
||||
{
|
||||
double time = MOOSTime(false);
|
||||
std::lock_guard<std::mutex> lock(m_mutexCcuState);
|
||||
m_qReceiveCcuStateBuffer.push(std::make_pair(time, s));
|
||||
}
|
||||
else
|
||||
@@ -201,6 +202,7 @@ bool udpComm::pushMsgToQueue(unsigned char *m)
|
||||
if(m_qReceiveCcuSetParmBuffer.size()<QUENUE_SIZE)
|
||||
{
|
||||
double time = MOOSTime(false);
|
||||
std::lock_guard<std::mutex> lock(m_mutexCcuSetParm);
|
||||
m_qReceiveCcuSetParmBuffer.push(std::make_pair(time, s));
|
||||
}
|
||||
else
|
||||
@@ -224,6 +226,7 @@ bool udpComm::pushMsgToQueue(unsigned char *m)
|
||||
if(m_qReceiveDisHighVolBusBuffer.size()<QUENUE_SIZE)
|
||||
{
|
||||
double time = MOOSTime(false);
|
||||
std::lock_guard<std::mutex> lock(m_mutexDisHighVolBus);
|
||||
m_qReceiveDisHighVolBusBuffer.push(std::make_pair(time, s));
|
||||
}
|
||||
else
|
||||
@@ -247,6 +250,7 @@ bool udpComm::pushMsgToQueue(unsigned char *m)
|
||||
if(m_qReceiveDisHighAVolBusBuffer.size()<QUENUE_SIZE)
|
||||
{
|
||||
double time = MOOSTime(false);
|
||||
std::lock_guard<std::mutex> lock(m_mutexDisHighAVolBus);
|
||||
m_qReceiveDisHighAVolBusBuffer.push(std::make_pair(time, s));
|
||||
}
|
||||
else
|
||||
@@ -270,6 +274,7 @@ bool udpComm::pushMsgToQueue(unsigned char *m)
|
||||
if(m_qReceiveDisHighBVolBusBuffer.size()<QUENUE_SIZE)
|
||||
{
|
||||
double time = MOOSTime(false);
|
||||
std::lock_guard<std::mutex> lock(m_mutexDisHighBVolBus);
|
||||
m_qReceiveDisHighBVolBusBuffer.push(std::make_pair(time, s));
|
||||
}
|
||||
else
|
||||
@@ -293,6 +298,7 @@ bool udpComm::pushMsgToQueue(unsigned char *m)
|
||||
if(m_qReceiveDisLowBusBuffer.size()<QUENUE_SIZE)
|
||||
{
|
||||
double time = MOOSTime(false);
|
||||
std::lock_guard<std::mutex> lock(m_mutexDisLowBus);
|
||||
m_qReceiveDisLowBusBuffer.push(std::make_pair(time, s));
|
||||
}
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user