anchao commented on code in PR #15202:
URL: https://github.com/apache/nuttx/pull/15202#discussion_r1886238968


##########
fs/inode/fs_files.c:
##########
@@ -76,17 +76,15 @@ static FAR struct file *files_fget_by_index(FAR struct 
filelist *list,
 
   filep = &list->fl_files[l1][l2];
 #ifdef CONFIG_FS_REFCOUNT
-  int32_t refs = 0;
-
   if (filep->f_inode != NULL)
     {
       /* When the reference count is zero but the inode has not yet been
        * released, At this point we should return a null pointer
        */
 
+      int32_t refs = atomic_read(&filep->f_refs);

Review Comment:
   we should keep the atomic_read in while loop:
   
   1. [CPU0]: atomic_read == 1
   2. [CPU1]: fs_reffilep + 1 == 2
   3. [CPU0]:atomic_try_cmpxchg(2, 1, 1 + 1)   <- alway fail and busy loop



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to