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/08/08 10:32:27 UTC

[GitHub] [incubator-nuttx] xiaoxiang781216 commented on a diff in pull request #6808: net/local:Make local udp send multi-thread safe

xiaoxiang781216 commented on code in PR #6808:
URL: https://github.com/apache/incubator-nuttx/pull/6808#discussion_r940084340


##########
net/local/local_sendmsg.c:
##########
@@ -334,6 +334,16 @@ static ssize_t local_sendto(FAR struct socket *psock,
       goto errout_with_halfduplex;
     }
 
+  /* Make sure that dgram is sent safely */
+
+  ret = nxsem_wait_uninterruptible(&conn->lc_sendsem);
+  if (ret < 0)
+    {
+      /* May fail because the task was canceled. */
+
+      return ret;

Review Comment:
   goto errout_with_sender and close lc_outfile



##########
net/local/local_conn.c:
##########
@@ -128,6 +128,16 @@ FAR struct local_conn_s *local_alloc(void)
       nxsem_init(&conn->lc_donesem, 0, 0);
       nxsem_set_protocol(&conn->lc_donesem, SEM_PRIO_NONE);
 
+#endif
+
+#ifdef CONFIG_NET_LOCAL_DGRAM

Review Comment:
   why check CONFIG_NET_LOCAL_DGRAM



##########
net/local/local_conn.c:
##########
@@ -128,6 +128,16 @@ FAR struct local_conn_s *local_alloc(void)
       nxsem_init(&conn->lc_donesem, 0, 0);
       nxsem_set_protocol(&conn->lc_donesem, SEM_PRIO_NONE);
 
+#endif
+
+#ifdef CONFIG_NET_LOCAL_DGRAM
+      /* This semaphore is used for sending udp dgram safely in multithread.
+       * local DGRAM consists of preamble,len,buf. Make sure they will
+       * not be garbled when multi-thread sends.
+       */
+
+      nxsem_init(&conn->lc_sendsem, 0, 1);

Review Comment:
   where destroy sem?



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