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:
ouyangxiangzhen 2024-09-14 18:04:50 +08:00 committed by archer
parent 9f36509c0b
commit 0373ba0fab
2 changed files with 7 additions and 24 deletions

View File

@ -134,16 +134,18 @@ int nxsig_notification(pid_t pid, FAR struct sigevent *event,
memcpy(&info.si_value, &event->sigev_value, sizeof(union sigval)); memcpy(&info.si_value, &event->sigev_value, sizeof(union sigval));
/* Used only by POSIX timer. Notice that it is UNSAFE, unless /* Used only by POSIX timer. Before the notification, we should
* we GUARANTEE that event->sigev_notify_thread_id is valid. * validate the tid and make sure that the notified thread is
* in same process with current thread.
*/ */
if (event->sigev_notify & SIGEV_THREAD_ID) if (event->sigev_notify & SIGEV_THREAD_ID)
{ {
rtcb = nxsched_get_tcb(event->sigev_notify_thread_id); FAR struct tcb_s *ptcb;
if (rtcb != NULL) 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 else
{ {

View File

@ -191,25 +191,6 @@ int timer_create(clockid_t clockid, FAR struct sigevent *evp,
if (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 */ /* Yes, copy the entire struct sigevent content */
memcpy(&ret->pt_event, evp, sizeof(struct sigevent)); memcpy(&ret->pt_event, evp, sizeof(struct sigevent));