CV-Bowen commented on code in PR #10706:
URL: https://github.com/apache/nuttx/pull/10706#discussion_r1375635957


##########
fs/vfs/fs_epoll.c:
##########
@@ -308,12 +311,22 @@ static int epoll_teardown(FAR epoll_head_t *eph, FAR 
struct epoll_event *evs,
 
   list_for_every_entry_safe(&eph->setup, epn, tepn, epoll_node_t, node)
     {
+      /* Only check the notifed fd */
+
+      if (epn->notified == false)

Review Comment:
   Done



##########
fs/vfs/fs_epoll.c:
##########
@@ -323,12 +336,52 @@ static int epoll_teardown(FAR epoll_head_t *eph, FAR 
struct epoll_event *evs,
               list_add_tail(&eph->teardown, &epn->node);
             }
         }
+      else
+        {
+          list_add_tail(&eph->teardown, &epn->node);
+        }
     }
 
   nxmutex_unlock(&eph->lock);
   return i;
 }
 
+/****************************************************************************
+ * Name: epoll_default_cb
+ *
+ * Description:
+ *   The default epoll callback function, this function do the final step of
+ *   poll notification.
+ *
+ * Input Parameters:
+ *   fds - The fds
+ *
+ * Returned Value:
+ *   None
+ *
+ ****************************************************************************/
+
+static void epoll_default_cb(FAR struct pollfd *fds)
+{
+  FAR epoll_node_t *epn = fds->arg;
+  int semcount = 0;
+
+  if (epn == NULL)

Review Comment:
   Done



##########
fs/vfs/fs_epoll.c:
##########
@@ -535,6 +590,7 @@ int epoll_ctl(int epfd, int op, int fd, FAR struct 
epoll_event *ev)
                     poll_fdsetup(fd, &epn->pfd, false);
 
                     epn->data        = ev->data;
+                    epn->notified    = false;

Review Comment:
   Done



##########
fs/vfs/fs_epoll.c:
##########
@@ -473,10 +526,12 @@ int epoll_ctl(int epfd, int op, int fd, FAR struct 
epoll_event *ev)
 
         epn = container_of(list_remove_head(&eph->free), epoll_node_t, node);
         epn->data        = ev->data;
+        epn->eph         = eph;

Review Comment:
   Done



##########
fs/vfs/fs_epoll.c:
##########
@@ -674,7 +675,13 @@ int epoll_pwait(int epfd, FAR struct epoll_event *evs,
       goto err;
     }
 
-  return epoll_teardown(eph, evs, maxevents);
+  ret = epoll_teardown(eph, evs, maxevents);
+  if (ret == 0 && timeout != 0)

Review Comment:
   Done



##########
fs/vfs/fs_epoll.c:
##########
@@ -48,9 +48,11 @@
 
 struct epoll_node_s
 {
-  struct list_node      node;
-  epoll_data_t          data;
-  struct pollfd         pfd;
+  struct list_node         node;
+  epoll_data_t             data;
+  struct pollfd            pfd;
+  FAR struct epoll_head_s *eph;

Review Comment:
   Done



##########
net/local/local_netpoll.c:
##########
@@ -119,7 +119,10 @@ static void local_inout_poll_cb(FAR struct pollfd *fds)
 {
   FAR struct pollfd *originfds = fds->arg;
 
-  poll_notify(&originfds, 1, fds->revents);
+  if (fds->revents != 0)

Review Comment:
   Move this check out of poll notify to make epoll_default_cb can know which 
fd is notifed. As mentioned in the commit, some drivers' poll implementations 
need we call the poll_setup() again when their internal states changed (e.g., 
local socket), so I move this check to poll callback and  epoll can know which 
fd is notified and setup it again in the next epoll_wait call.



##########
fs/vfs/fs_epoll.c:
##########
@@ -281,6 +283,7 @@ static int epoll_setup(FAR epoll_head_t *eph)
        */
 
       epn->pfd.revents = 0;
+      epn->notified    = false;

Review Comment:
   Done



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