You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by GitBox <gi...@apache.org> on 2021/09/06 08:39:38 UTC

[GitHub] [incubator-nuttx] anchao commented on a change in pull request #4433: net/devif/devif_callback.c: corrected the connection event list to work as FIFO instead of LIFO

anchao commented on a change in pull request #4433:
URL: https://github.com/apache/incubator-nuttx/pull/4433#discussion_r702714375



##########
File path: net/devif/devif_callback.c
##########
@@ -276,12 +301,29 @@ FAR struct devif_callback_s *
           dev->d_devcb = ret;
         }
 
-      /* Add the newly allocated instance to the head of the specified list */
+      /* Add the newly allocated instance to the tail of the specified list */
 
       if (list)
         {
-           ret->nxtconn = *list;
-           *list = ret;
+          ret->nxtconn = NULL;

Review comment:
       Hi @a-lunev how about sort the event list by default?
   
   ```
   diff --git a/net/devif/devif_callback.c b/net/devif/devif_callback.c
   index 1d49a7c09c..fad6e11d5d 100644
   --- a/net/devif/devif_callback.c
   +++ b/net/devif/devif_callback.c
   @@ -237,6 +237,7 @@ FAR struct devif_callback_s *
      devif_callback_alloc(FAR struct net_driver_s *dev,
                           FAR struct devif_callback_s **list)
    {
   +  FAR struct devif_callback_s *next;
      FAR struct devif_callback_s *ret;
    
      /* Check  the head of the free list */
   @@ -280,8 +281,22 @@ FAR struct devif_callback_s *
    
          if (list)
            {
   -           ret->nxtconn = *list;
   -           *list = ret;
   +          if (*list)
   +            {
   +              next = *list;
   +              while (next->nxtconn != NULL)
   +                {
   +                  next = next->nxtconn;
   +                }
   +
   +              next->nxtconn = ret;
   +            }
   +          else
   +            {
   +              *list = ret;
   +            }
   +
   +          ret->nxtconn = NULL;
            }
        }
    #ifdef CONFIG_DEBUG_FEATURES
   
   ```




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org