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

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

commit 049bd4149695035ebc542758cb27b82b3efec9c4
Author: likun17 <[email protected]>
AuthorDate: Mon Mar 17 14:36:47 2025 +0800

    system/uorb/test: Fix fd leak in test_multi_reversed().
    
    test_multi_reversed() subscribes to instance 2 of orb_multitest a second
    time and stores the new fd in sfds[2], overwriting the fd it opened
    earlier in the same function, so the first subscription is never
    closed.
    
    Reuse the existing subscription instead of opening a new one, and make
    the "failed launching task" messages of latency_test() and
    test_multi2() tell which task failed.
    
    Signed-off-by: likun17 <[email protected]>
---
 system/uorb/test/unit_test.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/system/uorb/test/unit_test.c b/system/uorb/test/unit_test.c
index 89897fb1f..e4c232b8f 100644
--- a/system/uorb/test/unit_test.c
+++ b/system/uorb/test/unit_test.c
@@ -216,7 +216,7 @@ static int latency_test(bool print)
 
   if (pthread_create(&pubsub_task, NULL, pubsubtest_thread_entry, NULL) < 0)
     {
-      test_fail("failed launching task");
+      test_fail("failed launching latency test task");
       goto out;
     }
 
@@ -606,9 +606,7 @@ static int test_multi_reversed(int *afds, int *sfds)
       return test_fail("mult. pub3 fail");
     }
 
-  /* subscribe to both topics and ensure valid data is received */
-
-  sfds[2] = orb_subscribe_multi(ORB_ID(orb_multitest), 2);
+  /* ensure valid data is received */
 
   if (OK != orb_copy(ORB_ID(orb_multitest), sfds[2], &sub_sample))
     {
@@ -737,7 +735,7 @@ static int test_multi2(void)
   if (pthread_create(&pubsub_task, &attr, pub_test_multi2_entry, NULL) < 0)
     {
       pthread_attr_destroy(&attr);
-      test_fail("failed launching task");
+      test_fail("failed launching test multi task");
       goto out;
     }
 

Reply via email to