You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by ma...@apache.org on 2023/01/28 12:45:18 UTC

[nuttx] branch master updated (8c52633bd0 -> 45e4bc5f33)

This is an automated email from the ASF dual-hosted git repository.

masayuki pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git


    from 8c52633bd0 fs: unlock tmpfs before free the file object
     new b9d70365a1 sched/wqueue: semaphore count should be consistent with the number of work entries.
     new 45e4bc5f33 sched/semaphore: correct the return value of sem_post()

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 sched/semaphore/sem_post.c  | 6 +++++-
 sched/wqueue/kwork_cancel.c | 6 ++++++
 2 files changed, 11 insertions(+), 1 deletion(-)


[nuttx] 01/02: sched/wqueue: semaphore count should be consistent with the number of work entries.

Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

masayuki pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git

commit b9d70365a1cd722018ca4feb3f26b1fa20294465
Author: chao an <an...@xiaomi.com>
AuthorDate: Sat Jan 28 13:24:04 2023 +0800

    sched/wqueue: semaphore count should be consistent with the number of work entries.
    
    The number of work entries will be inconsistent with semaphore count
    if the work is canceled, in extreme case, semaphore count will overflow
    and fallback to 0 the workqueue will stop scheduling the enqueue work.
    
    Signed-off-by: chao an <an...@xiaomi.com>
---
 sched/wqueue/kwork_cancel.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/sched/wqueue/kwork_cancel.c b/sched/wqueue/kwork_cancel.c
index 340d861ce5..fd8055ea04 100644
--- a/sched/wqueue/kwork_cancel.c
+++ b/sched/wqueue/kwork_cancel.c
@@ -88,6 +88,12 @@ static int work_qcancel(FAR struct kwork_wqueue_s *wqueue,
       else
         {
           dq_rem((FAR dq_entry_t *)work, &wqueue->q);
+
+          /* Semaphore count should be consistent with the number of
+           * work entries.
+           */
+
+          wqueue->sem.semcount--;
         }
 
       work->worker = NULL;


[nuttx] 02/02: sched/semaphore: correct the return value of sem_post()

Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

masayuki pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git

commit 45e4bc5f3301042284bfdb9dd9ba3662d4ee70a1
Author: chao an <an...@xiaomi.com>
AuthorDate: Sat Jan 28 13:37:46 2023 +0800

    sched/semaphore: correct the return value of sem_post()
    
    sem_post() should return EOVERFLOW if maximum allowable value for
    a semaphore would be exceeded.
    
    Reference:
    https://man7.org/linux/man-pages/man3/sem_post.3.html
    
    Signed-off-by: chao an <an...@xiaomi.com>
---
 sched/semaphore/sem_post.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/sched/semaphore/sem_post.c b/sched/semaphore/sem_post.c
index 2a0d72987d..6c721d27b0 100644
--- a/sched/semaphore/sem_post.c
+++ b/sched/semaphore/sem_post.c
@@ -89,7 +89,11 @@ int nxsem_post(FAR sem_t *sem)
 
   /* Check the maximum allowable value */
 
-  DEBUGASSERT(sem_count < SEM_VALUE_MAX);
+  if (sem_count >= SEM_VALUE_MAX)
+    {
+      leave_critical_section(flags);
+      return -EOVERFLOW;
+    }
 
   /* Perform the semaphore unlock operation, releasing this task as a
    * holder then also incrementing the count on the semaphore.