From 40338918d9132399ee0494d331930a05b7a13c67 Mon Sep 17 00:00:00 2001 From: lnlan Date: Mon, 11 Oct 2021 11:53:37 +0000 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8DPR520=E7=BC=BA?= =?UTF-8?q?=E9=99=B7=20=E3=80=90=E8=83=8C=E6=99=AF=E3=80=91=20https://gite?= =?UTF-8?q?e.com/openharmony/kernel=5Fliteos=5Fa/pulls/520=20=E4=B8=8A?= =?UTF-8?q?=E9=9D=A2=E4=BF=AE=E6=94=B9=EF=BC=8C=E4=BF=A1=E5=8F=B7=E5=A4=84?= =?UTF-8?q?=E7=90=86=E6=97=B6=E6=89=8D=E4=BC=9A=E9=87=8A=E6=94=BE=E7=94=B3?= =?UTF-8?q?=E8=AF=B7=E7=9A=84=E5=86=85=E5=AD=98=EF=BC=8C=E5=BD=93=E4=BF=A1?= =?UTF-8?q?=E5=8F=B7=E8=A2=AB=E5=B1=8F=E8=94=BD=EF=BC=8C=E4=B8=94=E4=B8=80?= =?UTF-8?q?=E7=9B=B4=E5=8F=91=E9=80=81=E8=AF=A5=E4=BF=A1=E5=8F=B7=E6=97=B6?= =?UTF-8?q?=EF=BC=8C=20=E5=86=85=E5=AD=98=E5=8D=A0=E7=94=A8=E4=BC=9A?= =?UTF-8?q?=E4=B8=8D=E6=96=AD=E5=8F=98=E5=A4=A7=20=E3=80=90=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E6=96=B9=E6=A1=88=E3=80=91=201.=20=E4=BF=A1=E5=8F=B7?= =?UTF-8?q?=E5=8F=91=E9=80=81=E6=97=B6=E5=B7=B2=E7=BB=8F=E6=9C=89=E8=AF=A5?= =?UTF-8?q?=E4=BF=A1=E5=8F=B7=E7=9A=84siginfo=E5=9C=A8=E9=93=BE=E8=A1=A8?= =?UTF-8?q?=E4=B8=AD=E6=97=B6=EF=BC=8C=E4=B8=8D=E5=86=8D=E9=87=8D=E6=96=B0?= =?UTF-8?q?=E7=94=B3=E8=AF=B7=EF=BC=8C=E9=87=8D=E5=A4=8D=E4=BD=BF=E7=94=A8?= =?UTF-8?q?=E4=B9=8B=E5=89=8D=E7=9A=84siginfo.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 【影响】 对现有的产品编译不会有影响。 re#I4DEG5 Signed-off-by: lanleinan Change-Id: I74b3b7ff0b9efb0179313af9a0c8d1e12d1db5bb --- kernel/base/ipc/los_signal.c | 39 +++++++++++++++++++++--------------- 1 file changed, 23 insertions(+), 16 deletions(-) diff --git a/kernel/base/ipc/los_signal.c b/kernel/base/ipc/los_signal.c index b598cae6..a4066845 100644 --- a/kernel/base/ipc/los_signal.c +++ b/kernel/base/ipc/los_signal.c @@ -71,37 +71,44 @@ STATIC VOID OsMoveTmpInfoToUnbInfo(sig_cb *sigcb, INT32 signo) { SigInfoListNode *tmpInfoNode = sigcb->tmpInfoListHead; SigInfoListNode **prevHook = &sigcb->tmpInfoListHead; - INT32 isFirstDel = 1; while (tmpInfoNode != NULL) { if (tmpInfoNode->info.si_signo == signo) { - /* In some case, many siginfos have same signo, only last one inserted list need copy to unbinfo. */ - if (isFirstDel) { - /* copy tmpinfo to unbinfo. */ - (VOID)memcpy_s(&sigcb->sigunbinfo, sizeof(siginfo_t), &tmpInfoNode->info, sizeof(siginfo_t)); - isFirstDel = 0; - } - /* delete tmpinfo from tmpList. */ + /* copy tmpinfo to unbinfo. */ + (VOID)memcpy_s(&sigcb->sigunbinfo, sizeof(siginfo_t), &tmpInfoNode->info, sizeof(siginfo_t)); + /* delete tmpinfo from tmpList. */ *prevHook = tmpInfoNode->next; (VOID)LOS_MemFree(m_aucSysMem0, tmpInfoNode); tmpInfoNode = *prevHook; - continue; + break; } prevHook = &tmpInfoNode->next; tmpInfoNode = tmpInfoNode->next; } - - return; } STATIC INT32 OsAddSigInfoToTmpList(sig_cb *sigcb, siginfo_t *info) { - SigInfoListNode *tmp = (SigInfoListNode *)LOS_MemAlloc(m_aucSysMem0, sizeof(SigInfoListNode)); - if (tmp == NULL) { - return LOS_NOK; + /* try to find the old siginfo */ + SigInfoListNode *tmp = sigcb->tmpInfoListHead; + 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)); - tmp->next = sigcb->tmpInfoListHead; - sigcb->tmpInfoListHead = tmp; return LOS_OK; }