You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by gn...@apache.org on 2020/04/10 14:18:19 UTC

[incubator-nuttx] 02/08: netlink: Shouldn't call netlink_notify_response in netlink_poll

This is an automated email from the ASF dual-hosted git repository.

gnutt pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git

commit 3421ec90b4c0aaae4831f97567d2e1efd9a277ba
Author: Xiang Xiao <xi...@xiaomi.com>
AuthorDate: Wed Apr 8 01:50:01 2020 +0800

    netlink: Shouldn't call netlink_notify_response in netlink_poll
    
    to avoid sleep inside netlink_poll
    
    Change-Id: Id801c2dae805455a9b91f2e091d001679f0b3d4b
    Signed-off-by: Xiang Xiao <xi...@xiaomi.com>
---
 net/netlink/netlink.h        | 17 ------------
 net/netlink/netlink_conn.c   | 62 --------------------------------------------
 net/netlink/netlink_sockif.c | 40 +---------------------------
 3 files changed, 1 insertion(+), 118 deletions(-)

diff --git a/net/netlink/netlink.h b/net/netlink/netlink.h
index e1e7c7d..ff745b5 100644
--- a/net/netlink/netlink.h
+++ b/net/netlink/netlink.h
@@ -262,23 +262,6 @@ netlink_get_response(FAR struct socket *psock);
 bool netlink_check_response(FAR struct socket *psock);
 
 /****************************************************************************
- * Name: netlink_notify_response
- *
- * Description:
- *   Notify a thread when a response is available.  The thread will be
- *   notified via work queue notifier when the response becomes available.
- *
- * Returned Value:
- *   Zero (OK) is returned if the response is already available.  No
- *     notification will be sent.
- *   One is returned if the notification was successfully setup.
- *   A negated errno value is returned on any failure.
- *
- ****************************************************************************/
-
-int netlink_notify_response(FAR struct socket *psock);
-
-/****************************************************************************
  * Name: netlink_route_sendto()
  *
  * Description:
diff --git a/net/netlink/netlink_conn.c b/net/netlink/netlink_conn.c
index f72876a..cbd18c5 100644
--- a/net/netlink/netlink_conn.c
+++ b/net/netlink/netlink_conn.c
@@ -432,66 +432,4 @@ bool netlink_check_response(FAR struct socket *psock)
   return (sq_peek(&conn->resplist) != NULL);
 }
 
-/****************************************************************************
- * Name: netlink_notify_response
- *
- * Description:
- *   Notify a thread when a response is available.  The thread will be
- *   notified via work queue notifier when the response becomes available.
- *
- * Returned Value:
- *   Zero (OK) is returned if the response is already available.  No
- *     notification will be sent.
- *   One is returned if the notification was successfully setup.
- *   A negated errno value is returned on any failure.
- *
- ****************************************************************************/
-
-int netlink_notify_response(FAR struct socket *psock)
-{
-  FAR struct netlink_conn_s *conn;
-  int ret = 0;
-
-  DEBUGASSERT(psock != NULL && psock->s_conn != NULL);
-  conn = (FAR struct netlink_conn_s *)psock->s_conn;
-
-  /* Check if the response is available */
-
-  net_lock();
-  if (((FAR struct netlink_response_s *)sq_peek(&conn->resplist)) == NULL)
-    {
-      sem_t waitsem;
-
-      /* No.. Set up a semaphore to notify us when a response is queued. */
-
-      (void)sem_init(&waitsem, 0, 0);
-      (void)nxsem_setprotocol(&waitsem, SEM_PRIO_NONE);
-
-      /* Set up a notifier to post the semaphore when a response is
-       * received.
-       */
-
-      ret = netlink_notifier_setup(netlink_response_available, conn,
-                                   &waitsem);
-      if (ret < 0)
-        {
-          nerr("ERROR: netlink_notifier_setup() failed: %d\n", ret);
-        }
-      else
-        {
-          /* Wait for a response to be queued */
-
-          _netlink_semtake(&waitsem);
-        }
-
-      /* Tear-down the notifier and the semaphore */
-
-      netlink_notifier_teardown(conn);
-      sem_destroy(&waitsem);
-    }
-
-  net_unlock();
-  return ret < 0 ? ret : OK;
-}
-
 #endif /* CONFIG_NET_NETLINK */
diff --git a/net/netlink/netlink_sockif.c b/net/netlink/netlink_sockif.c
index 3b8e498..45fc04e 100644
--- a/net/netlink/netlink_sockif.c
+++ b/net/netlink/netlink_sockif.c
@@ -561,7 +561,7 @@ static int netlink_poll(FAR struct socket *psock, FAR struct pollfd *fds,
                         bool setup)
 {
   FAR struct netlink_conn_s *conn;
-  int ret;
+  int ret = OK;
 
   DEBUGASSERT(psock != NULL && psock->s_conn != NULL);
   conn = (FAR struct netlink_conn_s *)psock->s_conn;
@@ -626,44 +626,6 @@ static int netlink_poll(FAR struct socket *psock, FAR struct pollfd *fds,
               conn->pollsem   = NULL;
               conn->pollevent = NULL;
             }
-          else
-            {
-              /* Call netlink_notify_response() to receive a notification
-               * when a response has been queued.
-               */
-
-              ret = netlink_notify_response(psock);
-              if (ret < 0)
-                {
-                  nerr("ERROR: netlink_notify_response() failed: %d\n", ret);
-                  netlink_notifier_teardown(conn);
-                  conn->pollsem   = NULL;
-                  conn->pollevent = NULL;
-                }
-              else if (ret == 0)
-                {
-                  /* The return value of zero means that a response is
-                   * already available and that no notification is
-                   * forthcoming.
-                   */
-
-                  netlink_notifier_teardown(conn);
-                  conn->pollsem   = NULL;
-                  conn->pollevent = NULL;
-                  fds->revents    = POLLIN;
-                  nxsem_post(fds->sem);
-                }
-              else
-                {
-                  ret = OK;
-                }
-            }
-        }
-      else
-        {
-          /* There will not be any wakeups coming?  Probably an error? */
-
-          ret = OK;
         }
 
       net_unlock();