You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by GitBox <gi...@apache.org> on 2022/04/06 20:31:40 UTC
[GitHub] [incubator-nuttx] pkarashchenko commented on a diff in pull request #5931: fix: pthread_rwlock_timedwrlock.
pkarashchenko commented on code in PR #5931:
URL: https://github.com/apache/incubator-nuttx/pull/5931#discussion_r844397502
##########
sched/semaphore/sem_wait.c:
##########
@@ -63,8 +63,9 @@
* returned on success. A negated errno value is returned on failure.
* Possible returned errors:
*
- * - EINVAL: Invalid attempt to get the semaphore
- * - EINTR: The wait was interrupted by the receipt of a signal.
+ * - EINVAL: Invalid attempt to get the semaphore
+ * - EINTR: The wait was interrupted by the receipt of a signal.
+ * - ETIMEOUT: The wait was interrupted by the receipt of a timeout signal.
Review Comment:
I do not support this change. It changes the behavior of a core semaphore object in favor of a partial implementation. In this case the `uninterruptible` waiting for semaphore does not make any sense. Despite there is an attempt to cover `pthread_rwlock` implementation only by checking `if (info->si_signo == SIGCONDTIMEDOUT)`, but this code does not distinguish between `pthread_cond_timedwait` and `pthread_rwlock_clockrdlock`/`pthread_rwlock_clockwrlock`. Also the user may simply choose the same signo value for other part of an application that does not use pthreads and this code will introduce unexpected side effects.
PR description states: "Upon return from the signal handler the thread shall resume waiting as if it is not interrupted.", but that goal is not achieved in this PR because the same `ts` value is used if `EINTR` condition is detected. I recommend to solve it in another way. Calculate the number of ticks elapsed from the start of `pthread_cond_clockwait()` till the point when `EINTR` is detected and resume waiting only for the remaining time if that is a positive value. In such way changes can be localized at `pthread_rwlock` level instead of changing the behavior of the core synchronization primitive.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org