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.git

commit 548a531d864e310d3fa2d942bbedcee684dcabe0
Author: raiden00pl <[email protected]>
AuthorDate: Thu Oct 22 12:55:04 2026 +0200

    wireless/ieee802154: purge the MAC device events on the last close
    
    close() purged the queued events while the device was still open and
    kept them after the last close, and a registered notification was never
    dropped, so the events of a process that closed the device were queued
    forever. Purge the events and drop the notification on the last close.
    
    Assisted-by: Claude Code
    Signed-off-by: raiden00pl <[email protected]>
---
 wireless/ieee802154/mac802154_device.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/wireless/ieee802154/mac802154_device.c 
b/wireless/ieee802154/mac802154_device.c
index a8c26f132ac..453472b4164 100644
--- a/wireless/ieee802154/mac802154_device.c
+++ b/wireless/ieee802154/mac802154_device.c
@@ -293,14 +293,19 @@ static int mac802154dev_close(FAR struct file *filep)
 
   kmm_free(opriv);
 
-  /* If there are now no open instances of the driver and a signal handler is
-   * not registered, purge the list of events.
+  /* If there are now no open instances of the driver, purge the list of
+   * events.  A registered notification is of no use without an instance to
+   * read the events, drop it.
    */
 
-  if (dev->md_open)
+  if (dev->md_open == NULL)
     {
       FAR struct ieee802154_primitive_s *primitive;
 
+#ifndef CONFIG_DISABLE_ALL_SIGNALS
+      dev->md_notify_registered = false;
+#endif
+
       primitive =
         (FAR struct ieee802154_primitive_s *)
         sq_remfirst(&dev->primitive_queue);
@@ -699,8 +704,7 @@ static int mac802154dev_notify(FAR struct mac802154_maccb_s 
*maccb,
    * to allocate new notifications.
    */
 
-  if (dev->enableevents &&
-      (dev->md_open != NULL || dev->md_notify_registered))
+  if (dev->enableevents && dev->md_open != NULL)
     {
       /* Get exclusive access to the driver structure.  We don't care about
        * any signals so if we see one, just go back to trying to get access

Reply via email to