fix: 修复sigwait等待到的信号值与获取的siginfo中的值不一致
【背景】 集成测试发送两个不同的信号,sigwait第二次等到的仍是第一个信号 经定位,信号在kill时会将相关的siginfo信息拷贝到taskcb的unbinfo中,sigwait 处理时从unbinfo拷贝给用户。若此信号发送时处于屏蔽状态,再有其他信号发送会覆盖 掉unbinfo,此时sigwait等待这个信号获取到的info已经被覆盖 【修改方案】 1. 每个任务添加一个siginfo缓存链表,在处理信号前夕从缓存链表取出info到unbinfo中 【影响】 对现有的产品编译不会有影响。 re #I3M12H Signed-off-by: lanleinan <lanleinan@163.com> Change-Id: If4b064c18773f8eca7419c665977260167b09810
This commit is contained in:
parent
81b474813b
commit
c3facd1b95
|
@ -498,6 +498,7 @@ LITE_OS_SEC_TEXT VOID OsTaskResourcesToFree(LosTaskCB *taskCB)
|
|||
OsTaskKernelResourcesToFree(syncSignal, topOfStack);
|
||||
|
||||
SCHEDULER_LOCK(intSave);
|
||||
OsClearSigInfoTmpList(&(taskCB->sig));
|
||||
OsInsertTCBToFreeList(taskCB);
|
||||
SCHEDULER_UNLOCK(intSave);
|
||||
}
|
||||
|
|
|
@ -132,6 +132,11 @@ struct sq_queue_s {
|
|||
};
|
||||
typedef struct sq_queue_s sq_queue_t;
|
||||
|
||||
typedef struct SigInfoListNode {
|
||||
struct SigInfoListNode *next;
|
||||
siginfo_t info;
|
||||
} SigInfoListNode;
|
||||
|
||||
typedef struct {
|
||||
sigset_t sigFlag;
|
||||
sigset_t sigPendFlag;
|
||||
|
@ -140,6 +145,7 @@ typedef struct {
|
|||
LOS_DL_LIST waitList;
|
||||
sigset_t sigwaitmask; /* Waiting for pending signals */
|
||||
siginfo_t sigunbinfo; /* Signal info when task unblocked */
|
||||
SigInfoListNode *tmpInfoListHead; /* Signal info List */
|
||||
unsigned int sigIntLock;
|
||||
void *sigContext;
|
||||
unsigned int count;
|
||||
|
@ -167,6 +173,7 @@ int OsSigSuspend(const sigset_t *set);
|
|||
VOID OsSigIntLock(VOID);
|
||||
VOID OsSigIntUnlock(VOID);
|
||||
INT32 OsTaskKillUnsafe(UINT32 taskID, INT32 signo);
|
||||
VOID OsClearSigInfoTmpList(sig_cb *sigcb);
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
|
|
|
@ -67,11 +67,60 @@ int OsSigIsMember(const sigset_t *set, int signo)
|
|||
return ret;
|
||||
}
|
||||
|
||||
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. */
|
||||
*prevHook = tmpInfoNode->next;
|
||||
(VOID)LOS_MemFree(m_aucSysMem0, tmpInfoNode);
|
||||
tmpInfoNode = *prevHook;
|
||||
continue;
|
||||
}
|
||||
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;
|
||||
}
|
||||
(VOID)memcpy_s(&tmp->info, sizeof(siginfo_t), info, sizeof(siginfo_t));
|
||||
tmp->next = sigcb->tmpInfoListHead;
|
||||
sigcb->tmpInfoListHead = tmp;
|
||||
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
VOID OsClearSigInfoTmpList(sig_cb *sigcb)
|
||||
{
|
||||
while (sigcb->tmpInfoListHead != NULL) {
|
||||
SigInfoListNode *tmpInfoNode = sigcb->tmpInfoListHead;
|
||||
sigcb->tmpInfoListHead = sigcb->tmpInfoListHead->next;
|
||||
(VOID)LOS_MemFree(m_aucSysMem0, tmpInfoNode);
|
||||
}
|
||||
}
|
||||
|
||||
STATIC INLINE VOID OsSigWaitTaskWake(LosTaskCB *taskCB, INT32 signo)
|
||||
{
|
||||
sig_cb *sigcb = &taskCB->sig;
|
||||
|
||||
if (!LOS_ListEmpty(&sigcb->waitList) && OsSigIsMember(&sigcb->sigwaitmask, signo)) {
|
||||
OsMoveTmpInfoToUnbInfo(sigcb, signo);
|
||||
OsTaskWakeClearPendMask(taskCB);
|
||||
OsSchedTaskWake(taskCB);
|
||||
OsSigEmptySet(&sigcb->sigwaitmask);
|
||||
|
@ -141,7 +190,10 @@ int OsTcbDispatch(LosTaskCB *stcb, siginfo_t *info)
|
|||
/* unmasked signal actions */
|
||||
OsSigAddSet(&sigcb->sigFlag, info->si_signo);
|
||||
}
|
||||
(void) memcpy_s(&sigcb->sigunbinfo, sizeof(siginfo_t), info, sizeof(siginfo_t));
|
||||
|
||||
if (OsAddSigInfoToTmpList(sigcb, info) == LOS_NOK) {
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
return OsPendingTaskWake(stcb, info->si_signo);
|
||||
}
|
||||
|
@ -516,6 +568,7 @@ int OsSigTimedWaitNoLock(sigset_t *set, siginfo_t *info, unsigned int timeout)
|
|||
if (clear) {
|
||||
sigcb->sigPendFlag ^= clear;
|
||||
ret = FindFirstSetedBit((UINT64)clear) + 1;
|
||||
OsMoveTmpInfoToUnbInfo(sigcb, ret);
|
||||
} else {
|
||||
OsSigAddSet(set, SIGKILL);
|
||||
OsSigAddSet(set, SIGSTOP);
|
||||
|
@ -529,7 +582,7 @@ int OsSigTimedWaitNoLock(sigset_t *set, siginfo_t *info, unsigned int timeout)
|
|||
sigcb->sigwaitmask = NULL_SIGNAL_SET;
|
||||
}
|
||||
if (info != NULL) {
|
||||
(void) memcpy_s(info, sizeof(siginfo_t), &sigcb->sigunbinfo, sizeof(siginfo_t));
|
||||
(VOID)memcpy_s(info, sizeof(siginfo_t), &sigcb->sigunbinfo, sizeof(siginfo_t));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
@ -657,6 +710,7 @@ VOID *OsSaveSignalContext(VOID *sp, VOID *newSp)
|
|||
sigcb->sigFlag |= process->sigShare;
|
||||
UINT32 signo = (UINT32)FindFirstSetedBit(sigcb->sigFlag) + 1;
|
||||
UINT32 sigVal = (UINT32)(UINTPTR)(sigcb->sigunbinfo.si_value.sival_ptr);
|
||||
OsMoveTmpInfoToUnbInfo(sigcb, signo);
|
||||
OsProcessExitCodeSignalSet(process, signo);
|
||||
sigcb->sigContext = sp;
|
||||
|
||||
|
|
Loading…
Reference in New Issue