!656 修复PR520的修改缺陷

Merge pull request !656 from lnlan/sigwait_patch
This commit is contained in:
openharmony_ci 2021-10-26 01:39:06 +00:00 committed by Gitee
commit 7676cdb886
1 changed files with 23 additions and 16 deletions

View File

@ -71,37 +71,44 @@ STATIC VOID OsMoveTmpInfoToUnbInfo(sig_cb *sigcb, INT32 signo)
{ {
SigInfoListNode *tmpInfoNode = sigcb->tmpInfoListHead; SigInfoListNode *tmpInfoNode = sigcb->tmpInfoListHead;
SigInfoListNode **prevHook = &sigcb->tmpInfoListHead; SigInfoListNode **prevHook = &sigcb->tmpInfoListHead;
INT32 isFirstDel = 1;
while (tmpInfoNode != NULL) { while (tmpInfoNode != NULL) {
if (tmpInfoNode->info.si_signo == signo) { if (tmpInfoNode->info.si_signo == signo) {
/* In some case, many siginfos have same signo, only last one inserted list need copy to unbinfo. */ /* copy tmpinfo to unbinfo. */
if (isFirstDel) { (VOID)memcpy_s(&sigcb->sigunbinfo, sizeof(siginfo_t), &tmpInfoNode->info, sizeof(siginfo_t));
/* copy tmpinfo to unbinfo. */ /* delete tmpinfo from tmpList. */
(VOID)memcpy_s(&sigcb->sigunbinfo, sizeof(siginfo_t), &tmpInfoNode->info, sizeof(siginfo_t));
isFirstDel = 0;
}
/* delete tmpinfo from tmpList. */
*prevHook = tmpInfoNode->next; *prevHook = tmpInfoNode->next;
(VOID)LOS_MemFree(m_aucSysMem0, tmpInfoNode); (VOID)LOS_MemFree(m_aucSysMem0, tmpInfoNode);
tmpInfoNode = *prevHook; tmpInfoNode = *prevHook;
continue; break;
} }
prevHook = &tmpInfoNode->next; prevHook = &tmpInfoNode->next;
tmpInfoNode = tmpInfoNode->next; tmpInfoNode = tmpInfoNode->next;
} }
return;
} }
STATIC INT32 OsAddSigInfoToTmpList(sig_cb *sigcb, siginfo_t *info) STATIC INT32 OsAddSigInfoToTmpList(sig_cb *sigcb, siginfo_t *info)
{ {
SigInfoListNode *tmp = (SigInfoListNode *)LOS_MemAlloc(m_aucSysMem0, sizeof(SigInfoListNode)); /* try to find the old siginfo */
if (tmp == NULL) { SigInfoListNode *tmp = sigcb->tmpInfoListHead;
return LOS_NOK; while (tmp != NULL) {
if (tmp->info.si_signo == info->si_signo) {
/* found it, break. */
break;
}
tmp = tmp->next;
} }
if (tmp == NULL) {
/* none, alloc new one */
tmp = (SigInfoListNode *)LOS_MemAlloc(m_aucSysMem0, sizeof(SigInfoListNode));
if (tmp == NULL) {
return LOS_NOK;
}
tmp->next = sigcb->tmpInfoListHead;
sigcb->tmpInfoListHead = tmp;
}
(VOID)memcpy_s(&tmp->info, sizeof(siginfo_t), info, sizeof(siginfo_t)); (VOID)memcpy_s(&tmp->info, sizeof(siginfo_t), info, sizeof(siginfo_t));
tmp->next = sigcb->tmpInfoListHead;
sigcb->tmpInfoListHead = tmp;
return LOS_OK; return LOS_OK;
} }