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

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

commit 95833033f9f5c045309c1c48d2af994c78791f6b
Author: raiden00pl <[email protected]>
AuthorDate: Thu Oct 22 17:47:04 2026 +0200

    wireless/ieee802154/i8sak: hold the daemon only while the blaster runs
    
    blaster requested the daemon before parsing its options and kept it on
    a help or error exit and on quit, and a failed socket bind exited the
    whole daemon from the blaster thread.
    
    Assisted-by: Claude Code
    Signed-off-by: raiden00pl <[email protected]>
---
 wireless/ieee802154/i8sak/i8sak_blaster.c | 35 +++++++++++++++++++++----------
 1 file changed, 24 insertions(+), 11 deletions(-)

diff --git a/wireless/ieee802154/i8sak/i8sak_blaster.c 
b/wireless/ieee802154/i8sak/i8sak_blaster.c
index d1bd107d0..c889e70a1 100644
--- a/wireless/ieee802154/i8sak/i8sak_blaster.c
+++ b/wireless/ieee802154/i8sak/i8sak_blaster.c
@@ -79,15 +79,10 @@ static inline void i8sak_blaster_start(FAR struct i8sak_s 
*i8sak)
 
 void i8sak_blaster_cmd(FAR struct i8sak_s *i8sak, int argc, FAR char *argv[])
 {
+  bool start = argc < 2;
+  bool quit = false;
   int option;
 
-  i8sak_requestdaemon(i8sak);
-
-  if (argc < 2)
-    {
-      i8sak_blaster_start(i8sak);
-    }
-
   while ((option = getopt(argc, argv, "hqp:f:")) != ERROR)
     {
       switch (option)
@@ -107,18 +102,18 @@ void i8sak_blaster_cmd(FAR struct i8sak_s *i8sak, int 
argc, FAR char *argv[])
             optind = -1;
             return;
           case 'q': /* Quit blaster */
-            i8sak->blasterenabled = false;
+            quit = true;
             break;
 
           case 'p': /* Inline change blaster period */
             i8sak->blasterperiod = atoi(optarg);
-            i8sak_blaster_start(i8sak);
+            start = true;
             break;
 
           case 'f': /* Inline change blaster frame */
             i8sak->payload_len = i8sak_str2payload(optarg,
                                                    &i8sak->payload[0]);
-            i8sak_blaster_start(i8sak);
+            start = true;
             break;
 
           case ':':
@@ -139,6 +134,22 @@ void i8sak_blaster_cmd(FAR struct i8sak_s *i8sak, int 
argc, FAR char *argv[])
             i8sak_cmd_error(i8sak); /* This exits for us */
         }
     }
+
+  /* The blaster holds the daemon while it runs */
+
+  if (quit)
+    {
+      if (i8sak->blasterenabled)
+        {
+          i8sak->blasterenabled = false;
+          i8sak_releasedaemon(i8sak);
+        }
+    }
+  else if (start && !i8sak->blasterenabled)
+    {
+      i8sak_requestdaemon(i8sak);
+      i8sak_blaster_start(i8sak);
+    }
 }
 
 /****************************************************************************
@@ -161,7 +172,9 @@ pthread_addr_t i8sak_blaster_thread(pthread_addr_t arg)
                sizeof(struct sockaddr_in6)) < 0)
         {
           fprintf(stderr, "ERROR: failure to bind sock: %d\n", errno);
-          exit(1);
+          i8sak->blasterenabled = false;
+          i8sak_releasedaemon(i8sak);
+          return NULL;
         }
     }
 #endif

Reply via email to