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 2021/07/06 23:47:53 UTC

[GitHub] [incubator-nuttx] yamt commented on a change in pull request #4080: net/socket: add SO_SNDBUF support

yamt commented on a change in pull request #4080:
URL: https://github.com/apache/incubator-nuttx/pull/4080#discussion_r664939462



##########
File path: net/tcp/tcp_wrbuffer.c
##########
@@ -152,17 +152,31 @@ uint32_t tcp_wrbuffer_inqueue_size(FAR struct tcp_conn_s *conn)
  *   of TCP data is about to sent
  *
  * Input Parameters:
- *   None
+ *   conn - The TCP connection of interest
  *
  * Assumptions:
  *   Called from user logic with the network locked.
  *
  ****************************************************************************/
 
-FAR struct tcp_wrbuffer_s *tcp_wrbuffer_alloc(void)
+FAR struct tcp_wrbuffer_s *tcp_wrbuffer_alloc(FAR struct tcp_conn_s *conn)
 {
   FAR struct tcp_wrbuffer_s *wrb;
 
+#if CONFIG_NET_SEND_BUFSIZE > 0
+  if (conn)
+    {
+      /* If the send buffer size exceeds the send limit, wait for the write
+       * buffer to be released
+       */
+
+      while (tcp_wrbuffer_inqueue_size(conn) > conn->snd_bufs)
+        {
+          net_lockedwait_uninterruptible(&conn->snd_sem);

Review comment:
       i guess this kind of things should be interruptible. but it isn't a new problem in this change.

##########
File path: net/tcp/tcp_wrbuffer.c
##########
@@ -105,6 +105,44 @@ void tcp_wrbuffer_initialize(void)
   nxsem_set_protocol(&g_wrbuffer.sem, SEM_PRIO_NONE);
 }
 
+/****************************************************************************
+ * Name: tcp_wrbuffer_inqueue_size
+ *
+ * Description:
+ *   Get the in-queued write buffer size from connection
+ *
+ * Input Parameters:
+ *   conn - The TCP connection of interest
+ *
+ * Assumptions:
+ *   Called from user logic with the network locked.
+ *
+ ****************************************************************************/
+
+uint32_t tcp_wrbuffer_inqueue_size(FAR struct tcp_conn_s *conn)
+{
+  FAR struct tcp_wrbuffer_s *wrb;
+  FAR sq_entry_t *entry;
+  uint32_t total = 0;
+
+  if (conn)
+    {
+      for (entry = sq_peek(&conn->unacked_q); entry; entry = sq_next(entry))
+        {
+          wrb = (FAR struct tcp_wrbuffer_s *)entry;
+          total += TCP_WBSENT(wrb);
+        }
+
+      for (entry = sq_peek(&conn->write_q); entry; entry = sq_next(entry))
+        {
+          wrb = (FAR struct tcp_wrbuffer_s *)entry;
+          total += TCP_WBSENT(wrb);

Review comment:
       TCP_WBSENT is on-wire bytes, which is not appropriate thing to look at for SO_SNDBUF.
   
   i guess TCP_WBPKTLEN is more appropriate. how do you think?




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