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 6b4561a1558f82ede1155e2836d6f08de107683f
Author: raiden00pl <[email protected]>
AuthorDate: Thu Oct 22 17:47:04 2026 +0200

    wireless/ieee802154/i8sak: end the command when the daemon fails to start
    
    A daemon that failed to open the device never signalled its start, so
    the caller blocked forever, and a failed start left the daemon user
    counted.  i8sak_requestdaemon() ends the command on any failure.
    
    Assisted-by: Claude Code
    Signed-off-by: raiden00pl <[email protected]>
---
 wireless/ieee802154/i8sak/i8sak.h      |  3 ++-
 wireless/ieee802154/i8sak/i8sak_main.c | 25 ++++++++++++++++++++-----
 2 files changed, 22 insertions(+), 6 deletions(-)

diff --git a/wireless/ieee802154/i8sak/i8sak.h 
b/wireless/ieee802154/i8sak/i8sak.h
index b5f826e09..3467e9a16 100644
--- a/wireless/ieee802154/i8sak/i8sak.h
+++ b/wireless/ieee802154/i8sak/i8sak.h
@@ -99,6 +99,7 @@ struct i8sak_s
 
   bool initialized      : 1;
   bool daemon_shutdown  : 1;
+  bool daemon_failed    : 1;
   bool verbose          : 1;
   bool acceptall        : 1;
   bool assoc            : 1;
@@ -188,7 +189,7 @@ struct i8sak_s
  * Public Function Prototypes
  ****************************************************************************/
 
-int i8sak_requestdaemon(FAR struct i8sak_s *i8sak);
+void i8sak_requestdaemon(FAR struct i8sak_s *i8sak);
 int i8sak_releasedaemon(FAR struct i8sak_s *i8sak);
 
 uint8_t   i8sak_char2nibble (char ch);
diff --git a/wireless/ieee802154/i8sak/i8sak_main.c 
b/wireless/ieee802154/i8sak/i8sak_main.c
index 44173fa82..590932fa9 100644
--- a/wireless/ieee802154/i8sak/i8sak_main.c
+++ b/wireless/ieee802154/i8sak/i8sak_main.c
@@ -168,7 +168,7 @@ FAR const char *g_ieee802154_status_string[] =
  *
  ****************************************************************************/
 
-int i8sak_requestdaemon(FAR struct i8sak_s *i8sak)
+void i8sak_requestdaemon(FAR struct i8sak_s *i8sak)
 {
   char daemonname[I8SAK_MAX_DAEMONNAME];
   int ret;
@@ -178,7 +178,7 @@ int i8sak_requestdaemon(FAR struct i8sak_s *i8sak)
   if (ret < 0)
     {
       DEBUGASSERT(ret == EINTR);
-      return ret;
+      i8sak_cmd_error(i8sak);
     }
 
   if (++i8sak->daemonusers == 1)
@@ -201,6 +201,7 @@ int i8sak_requestdaemon(FAR struct i8sak_s *i8sak)
 #endif
 
       i8sak->daemon_shutdown = false;
+      i8sak->daemon_failed = false;
       i8sak->daemon_pid = task_create(daemonname,
                                       CONFIG_IEEE802154_I8SAK_PRIORITY,
                                       CONFIG_IEEE802154_I8SAK_STACKSIZE,
@@ -209,8 +210,9 @@ int i8sak_requestdaemon(FAR struct i8sak_s *i8sak)
       if (i8sak->daemon_pid < 0)
         {
           fprintf(stderr, "failed to start daemon\n");
+          i8sak->daemonusers = 0;
           sem_post(&i8sak->daemonlock);
-          return ERROR;
+          i8sak_cmd_error(i8sak);
         }
 
       /* Use the semaphore to wait for daemon to start before returning */
@@ -219,13 +221,22 @@ int i8sak_requestdaemon(FAR struct i8sak_s *i8sak)
       if (ret < 0)
         {
           fprintf(stderr, "i8sak:interrupted while daemon starting\n");
+          i8sak->daemonusers = 0;
           sem_post(&i8sak->daemonlock);
-          return ret;
+          i8sak_cmd_error(i8sak);
+        }
+
+      /* The daemon signals a failed start too */
+
+      if (i8sak->daemon_failed)
+        {
+          i8sak->daemonusers = 0;
+          sem_post(&i8sak->daemonlock);
+          i8sak_cmd_error(i8sak);
         }
     }
 
   sem_post(&i8sak->daemonlock);
-  return 0;
 }
 
 /****************************************************************************
@@ -773,6 +784,8 @@ static int i8sak_daemon(int argc, FAR char *argv[])
           fprintf(stderr, "ERROR: cannot open %s, errno=%d\n",
                   i8sak->ifname, errno);
           ret = errno;
+          i8sak->daemon_failed = true;
+          sem_post(&i8sak->sigsem);
           return ret;
         }
     }
@@ -784,6 +797,8 @@ static int i8sak_daemon(int argc, FAR char *argv[])
         {
           fprintf(stderr, "ERROR: failed to open socket, errno=%d\n", errno);
           ret = errno;
+          i8sak->daemon_failed = true;
+          sem_post(&i8sak->sigsem);
           return ret;
         }
     }

Reply via email to