Donny9 commented on code in PR #16431:
URL: https://github.com/apache/nuttx/pull/16431#discussion_r2104480060


##########
fs/inode/fs_files.c:
##########
@@ -476,14 +479,32 @@ void files_putlist(FAR struct filelist *list)
    * because there should not be any references in this context.
    */
 
+#ifdef CONFIG_FS_REFCOUNT
+again:
+  loop = false;
+#endif
   for (i = list->fl_rows - 1; i >= 0; i--)
     {
       for (j = CONFIG_NFILE_DESCRIPTORS_PER_BLOCK - 1; j >= 0; j--)
         {
+#ifdef CONFIG_FS_REFCOUNT
+          if (fs_putfilep(&list->fl_files[i][j]) > 0)

Review Comment:
   > I mean another CPU can be performing a write/read/whatever operation while 
another CPU exit()'s the process. This is userspace racing against itself. The 
kernel must be able to endure this.
   
   @pussuw 
   The scenario you're describing should be: 
   **A task contains multiple pthreads, where CPU A is scheduling one of the 
pthreads and is currently performing read/write operations, while another CPU B 
is executing the exit process for that task.** 
   
   In this situation, we ensure in group_release that all child pthreads exit 
first via group_remove_children, and then the main task's exit is completed, 
releasing all file descriptors (fds). There are no issues with this; it's been 
done this way before, and it has no relation to the modifications in the 
current patch.



-- 
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-unsubscr...@nuttx.apache.org

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

Reply via email to