sched/signal: Simplified Implementation for SIGEV_THREAD_TID.
This commit simplified the implementation for SIGEV_THREAD_TID. Signed-off-by: ouyangxiangzhen <ouyangxiangzhen@xiaomi.com>
This commit is contained in:
parent
9f36509c0b
commit
0373ba0fab
|
@ -134,16 +134,18 @@ int nxsig_notification(pid_t pid, FAR struct sigevent *event,
|
|||
|
||||
memcpy(&info.si_value, &event->sigev_value, sizeof(union sigval));
|
||||
|
||||
/* Used only by POSIX timer. Notice that it is UNSAFE, unless
|
||||
* we GUARANTEE that event->sigev_notify_thread_id is valid.
|
||||
/* Used only by POSIX timer. Before the notification, we should
|
||||
* validate the tid and make sure that the notified thread is
|
||||
* in same process with current thread.
|
||||
*/
|
||||
|
||||
if (event->sigev_notify & SIGEV_THREAD_ID)
|
||||
{
|
||||
rtcb = nxsched_get_tcb(event->sigev_notify_thread_id);
|
||||
if (rtcb != NULL)
|
||||
FAR struct tcb_s *ptcb;
|
||||
ptcb = nxsched_get_tcb(event->sigev_notify_thread_id);
|
||||
if (ptcb != NULL && ptcb->group == rtcb->group)
|
||||
{
|
||||
return nxsig_tcbdispatch(rtcb, &info);
|
||||
return nxsig_tcbdispatch(ptcb, &info);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -191,25 +191,6 @@ int timer_create(clockid_t clockid, FAR struct sigevent *evp,
|
|||
|
||||
if (evp)
|
||||
{
|
||||
FAR struct tcb_s *ntcb;
|
||||
|
||||
/* Check the SIGEV_THREAD_ID and validate the tid */
|
||||
|
||||
if (evp->sigev_notify & SIGEV_THREAD_ID)
|
||||
{
|
||||
/* Make sure that the notified thread is
|
||||
* in same process with current thread.
|
||||
*/
|
||||
|
||||
ntcb = nxsched_get_tcb(evp->sigev_notify_thread_id);
|
||||
|
||||
if (ntcb == NULL || tcb->group != ntcb->group)
|
||||
{
|
||||
set_errno(EINVAL);
|
||||
return ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
/* Yes, copy the entire struct sigevent content */
|
||||
|
||||
memcpy(&ret->pt_event, evp, sizeof(struct sigevent));
|
||||
|
|
Loading…
Reference in New Issue