POSIX: ECANCELED returned by sem_wait

2022-05-26 Thread Petro Karashchenko
Hi, I have a question about sem_wait. Current implementation in NuttX can return failure and set errno to ECANCELED in case if the semaphore wait is done while code is inside the cancelation point. However I do not see ECANCELED in the POSIX description of sem_wait. Can anyone bring some more ligh

Re: POSIX: ECANCELED returned by sem_wait

2022-05-26 Thread Alan Carvalho de Assis
Hi Petro, According with OpenGroup there is not ECANCELED as possible return: https://pubs.opengroup.org/onlinepubs/7908799/xsh/sem_wait.html Maybe it should be replaced with EINTR case it was cancelled because was interrupted by a signal. BR, Alan On 5/26/22, Petro Karashchenko wrote: > Hi,

Re: POSIX: ECANCELED returned by sem_wait

2022-05-26 Thread Petro Karashchenko
Hi, This question arises during the review of one PRs. Indeed, it seems that ECANCELED should never be returned to the app because leave_cancellation_point() should terminate the task; however there are quite a few places in code that check ECANCELED returned by semaphore. Those are: - mm_takesema

Re: POSIX: ECANCELED returned by sem_wait

2022-05-26 Thread Gregory Nutt
nxsem_wait() is not a cancellation point. There are no cancellation points within the OS, onl nsy at the application interface. So sem_wait() is a cancellation point; It nxsem_wait() will not. nxsem_wait() will not cause the thread calling nxsem_wait() but will return ECANCELED. In these ca

Re: POSIX: ECANCELED returned by sem_wait

2022-05-26 Thread Petro Karashchenko
Hi, Ok. That makes sense. But there is a strane code in sem_wait: if (enter_cancellation_point()) { #ifdef CONFIG_CANCELLATION_POINTS /* If there is a pending cancellation, then do not perform * the wait. Exit now with ECANCELED. */ errcode = ECANCELED; got