条件竞争问题整改

Signed-off-by: wulimm <hanjing5@huawei.com>
This commit is contained in:
wulimm 2024-06-29 09:52:19 +00:00 committed by Gitee
parent 3bcc4f3d73
commit 9e165f124e
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 3 additions and 7 deletions

View File

@ -57,7 +57,7 @@ private:
void ProcessPendingList();
void EraseListenEvent(HRilEventMessage &eventMsg, int32_t index);
void ProcessEvents(fd_set *rfds, int32_t number);
bool GetEventMessageFromPendingList(HRilEventMessage *eventMsg);
bool HasEventMessageFromPendingList(HRilEventMessage *eventMsg);
void CopyReadFds(fd_set *rfds);
std::mutex listLock_;

View File

@ -77,7 +77,7 @@ void HRilEvent::ProcessTimerList()
}
}
bool HRilEvent::GetEventMessageFromPendingList(HRilEventMessage *eventMsg)
bool HRilEvent::HasEventMessageFromPendingList(HRilEventMessage *eventMsg)
{
std::lock_guard<std::mutex> mutexLock(listLock_);
std::list<HRilEventMessage>::iterator eventIt = pendingList_.begin();
@ -96,11 +96,7 @@ bool HRilEvent::GetEventMessageFromPendingList(HRilEventMessage *eventMsg)
void HRilEvent::ProcessPendingList()
{
HRilEventMessage evMsg = {};
while (1) {
if (!GetEventMessageFromPendingList(&evMsg)) {
break;
}
while (HasEventMessageFromPendingList(&evMsg)) {
if (evMsg.func != nullptr) {
evMsg.func(evMsg.fd, 0, evMsg.param);
}