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 2022/10/05 19:55:19 UTC

[GitHub] [incubator-nuttx] CV-Bowen commented on a diff in pull request #7207: fs/poll: using callback mechanism to implement poll notification

CV-Bowen commented on code in PR #7207:
URL: https://github.com/apache/incubator-nuttx/pull/7207#discussion_r985246238


##########
fs/vfs/fs_poll.c:
##########
@@ -317,15 +349,10 @@ void poll_notify(FAR struct pollfd **afds, int nfds, pollevent_t eventset)
               fds->revents &= ~POLLOUT;
             }
 
-          if (fds->revents != 0)
+          if (fds->revents != 0 && fds->cb)

Review Comment:
   Done



##########
fs/vfs/fs_poll.c:
##########
@@ -277,6 +279,37 @@ static inline int poll_teardown(FAR struct pollfd *fds, nfds_t nfds,
  * Public Functions
  ****************************************************************************/
 
+/****************************************************************************
+ * Name: poll_default_cb
+ *
+ * Description:
+ *   The default poll callback function, this function do the final step of
+ *   poll notification.
+ *
+ * Input Parameters:
+ *   fds - The fds
+ *
+ * Returned Value:
+ *   None
+ *
+ ****************************************************************************/
+
+void poll_default_cb(FAR struct pollfd *fds)
+{
+  int semcount = 0;
+  FAR sem_t *pollsem;

Review Comment:
   Let's keep this, declare local variable in the beginning of the function is better for me.



##########
fs/vfs/fs_poll.c:
##########
@@ -277,6 +279,37 @@ static inline int poll_teardown(FAR struct pollfd *fds, nfds_t nfds,
  * Public Functions
  ****************************************************************************/
 
+/****************************************************************************
+ * Name: poll_default_cb
+ *
+ * Description:
+ *   The default poll callback function, this function do the final step of
+ *   poll notification.
+ *
+ * Input Parameters:
+ *   fds - The fds
+ *
+ * Returned Value:
+ *   None
+ *
+ ****************************************************************************/
+
+void poll_default_cb(FAR struct pollfd *fds)
+{
+  int semcount = 0;
+  FAR sem_t *pollsem;
+
+  if (fds->args != NULL)
+    {
+      pollsem = (FAR sem_t *)fds->args;

Review Comment:
   Why not need?



##########
include/sys/poll.h:
##########
@@ -117,7 +122,8 @@ struct pollfd
   /* Non-standard fields used internally by NuttX. */
 
   FAR void    *ptr;     /* The psock or file being polled */
-  FAR sem_t   *sem;     /* Pointer to semaphore used to post output event */
+  FAR void    *args;    /* The poll callback function arguments */
+  FAR pollcb_t cb;      /* The poll callback function */

Review Comment:
   Done



##########
include/sys/poll.h:
##########
@@ -117,7 +122,8 @@ struct pollfd
   /* Non-standard fields used internally by NuttX. */
 
   FAR void    *ptr;     /* The psock or file being polled */
-  FAR sem_t   *sem;     /* Pointer to semaphore used to post output event */
+  FAR void    *args;    /* The poll callback function arguments */

Review Comment:
   Done



##########
include/sys/poll.h:
##########
@@ -144,6 +150,8 @@ int ppoll(FAR struct pollfd *fds, nfds_t nfds,
           FAR const struct timespec *timeout_ts,
           FAR const sigset_t *sigmask);
 
+void poll_default_cb(FAR struct pollfd *fds);

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

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