Re: POSIX: ECANCELED returned by sem_wait

2022-05-27 Thread Petro Karashchenko
Ok. Let's fill the issue and clean-up sem_wait as well as I met that code in sem_wait only, so other places should never return ECANCELED. пт, 27 трав. 2022 р. о 17:07 Gregory Nutt пише: > > > Yes and no. I've posted a code from sem_wait that checks if a > cancellation > > is pending but cannot

Re: POSIX: ECANCELED returned by sem_wait

2022-05-27 Thread Gregory Nutt
Yes and no. I've posted a code from sem_wait that checks if a cancellation is pending but cannot be performed due to the nesting level, so enter_cancellation_point will just increment the nested count and leave_cancellation_point will just decrement it. In this case ECANCELED will be returned b

Re: POSIX: ECANCELED returned by sem_wait

2022-05-27 Thread Petro Karashchenko
It was added by this commit commit 9568600ab19ef7da61ae7de4b43f1fc075556102 Author: Gregory Nutt Date: Wed Oct 4 15:22:27 2017 -0600 Squashed commit of the following: This commit backs out most of commit b4747286b19d3b15193b2a5e8a0fe48fa0a8638c. That change was added because sem_

Re: POSIX: ECANCELED returned by sem_wait

2022-05-27 Thread Petro Karashchenko
Yes and no. I've posted a code from sem_wait that checks if a cancellation is pending but cannot be performed due to the nesting level, so enter_cancellation_point will just increment the nested count and leave_cancellation_point will just decrement it. In this case ECANCELED will be returned by se

Re: POSIX: ECANCELED returned by sem_wait

2022-05-27 Thread Gregory Nutt
On 5/27/2022 12:52 AM, Petro Karashchenko wrote: 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 ECA

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

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, 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 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,

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