You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by "xiaoxiang781216 (via GitHub)" <gi...@apache.org> on 2024/02/28 18:15:41 UTC

[PR] Local socket improvement [nuttx]

xiaoxiang781216 opened a new pull request, #11804:
URL: https://github.com/apache/nuttx/pull/11804

   ## Summary
   
   - local: correct shutdown state when use UDP mode
   - net/local: Remove the unused lc_psock from local_conn_s
   - net/local: Initialize lc_crefs to 1
   - net/local: Remove the check of SOCK_STREAM before local_stream_connect
   - net/local: Add local_freectl to avoid the code duplicaton
   
   ## Impact
   
   local socket
   
   ## Testing
   
   internal testing


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


Re: [PR] Minor local socket improvement [nuttx]

Posted by "wengzhe (via GitHub)" <gi...@apache.org>.
wengzhe commented on code in PR #11804:
URL: https://github.com/apache/nuttx/pull/11804#discussion_r1507114720


##########
net/local/local_sendmsg.c:
##########
@@ -417,14 +426,7 @@ ssize_t local_sendmsg(FAR struct socket *psock, FAR struct msghdr *msg,
   if (len < 0 && count > 0)
     {
       net_lock();
-
-      while (count-- > 0)
-        {
-          file_close(conn->lc_cfps[--conn->lc_cfpcount]);
-          kmm_free(conn->lc_cfps[conn->lc_cfpcount]);
-          conn->lc_cfps[conn->lc_cfpcount] = NULL;
-        }
-
+      local_freectl(conn, count);

Review Comment:
   OK, I see.



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


Re: [PR] Minor local socket improvement [nuttx]

Posted by "xiaoxiang781216 (via GitHub)" <gi...@apache.org>.
xiaoxiang781216 commented on PR #11804:
URL: https://github.com/apache/nuttx/pull/11804#issuecomment-1970677824

   > can you please add a commit description
   
   The complex changes have the ommmit description, the commit messag is enough for the simple change. @jerpelea 


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


Re: [PR] Minor local socket improvement [nuttx]

Posted by "xiaoxiang781216 (via GitHub)" <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #11804:
URL: https://github.com/apache/nuttx/pull/11804#discussion_r1507100414


##########
net/local/local_sendmsg.c:
##########
@@ -417,14 +426,7 @@ ssize_t local_sendmsg(FAR struct socket *psock, FAR struct msghdr *msg,
   if (len < 0 && count > 0)
     {
       net_lock();
-
-      while (count-- > 0)
-        {
-          file_close(conn->lc_cfps[--conn->lc_cfpcount]);
-          kmm_free(conn->lc_cfps[conn->lc_cfpcount]);
-          conn->lc_cfps[conn->lc_cfpcount] = NULL;
-        }
-
+      local_freectl(conn, count);

Review Comment:
   No, the old code free the wrong array.



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


Re: [PR] Minor local socket improvement [nuttx]

Posted by "xiaoxiang781216 (via GitHub)" <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #11804:
URL: https://github.com/apache/nuttx/pull/11804#discussion_r1507103428


##########
net/local/local_sendmsg.c:
##########
@@ -124,19 +135,11 @@ static int local_sendctl(FAR struct local_conn_s *conn,
     }
 
   net_unlock();
-
   return count;
 
 fail:
-  while (i-- > 0)
-    {
-      file_close(peer->lc_cfps[--peer->lc_cfpcount]);
-      kmm_free(peer->lc_cfps[peer->lc_cfpcount]);
-      peer->lc_cfps[peer->lc_cfpcount] = NULL;
-    }
-
+  local_freectl(conn, count);

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


Re: [PR] Minor local socket improvement [nuttx]

Posted by "xiaoxiang781216 (via GitHub)" <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #11804:
URL: https://github.com/apache/nuttx/pull/11804#discussion_r1507103899


##########
net/local/local_sendmsg.c:
##########
@@ -58,6 +58,18 @@
  ****************************************************************************/
 
 #ifdef CONFIG_NET_LOCAL_SCM
+static void local_freectl(FAR struct local_conn_s *conn, int count)
+{
+  FAR struct local_conn_s *peer = conn->lc_peer;
+
+  while (count-- > 0)
+    {
+      file_close(peer->lc_cfps[--peer->lc_cfpcount]);
+      kmm_free(peer->lc_cfps[peer->lc_cfpcount]);
+      peer->lc_cfps[peer->lc_cfpcount] = NULL;
+    }

Review Comment:
   but we need free file handle in peer slot, not self.



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


Re: [PR] Minor local socket improvement [nuttx]

Posted by "acassis (via GitHub)" <gi...@apache.org>.
acassis merged PR #11804:
URL: https://github.com/apache/nuttx/pull/11804


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


Re: [PR] Minor local socket improvement [nuttx]

Posted by "wengzhe (via GitHub)" <gi...@apache.org>.
wengzhe commented on code in PR #11804:
URL: https://github.com/apache/nuttx/pull/11804#discussion_r1507082013


##########
net/local/local_sendmsg.c:
##########
@@ -417,14 +426,7 @@ ssize_t local_sendmsg(FAR struct socket *psock, FAR struct msghdr *msg,
   if (len < 0 && count > 0)
     {
       net_lock();
-
-      while (count-- > 0)
-        {
-          file_close(conn->lc_cfps[--conn->lc_cfpcount]);
-          kmm_free(conn->lc_cfps[conn->lc_cfpcount]);
-          conn->lc_cfps[conn->lc_cfpcount] = NULL;
-        }
-
+      local_freectl(conn, count);

Review Comment:
   Note: We need to free `conn` with `count` here, but `peer` with `i` above.



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


Re: [PR] Minor local socket improvement [nuttx]

Posted by "wengzhe (via GitHub)" <gi...@apache.org>.
wengzhe commented on code in PR #11804:
URL: https://github.com/apache/nuttx/pull/11804#discussion_r1507071171


##########
net/local/local_sendmsg.c:
##########
@@ -124,19 +135,11 @@ static int local_sendctl(FAR struct local_conn_s *conn,
     }
 
   net_unlock();
-
   return count;
 
 fail:
-  while (i-- > 0)
-    {
-      file_close(peer->lc_cfps[--peer->lc_cfpcount]);
-      kmm_free(peer->lc_cfps[peer->lc_cfpcount]);
-      peer->lc_cfps[peer->lc_cfpcount] = NULL;
-    }
-
+  local_freectl(conn, count);

Review Comment:
   ```suggestion
     local_freectl(peer, i);
   ```



##########
net/local/local_sendmsg.c:
##########
@@ -58,6 +58,18 @@
  ****************************************************************************/
 
 #ifdef CONFIG_NET_LOCAL_SCM
+static void local_freectl(FAR struct local_conn_s *conn, int count)
+{
+  FAR struct local_conn_s *peer = conn->lc_peer;
+
+  while (count-- > 0)
+    {
+      file_close(peer->lc_cfps[--peer->lc_cfpcount]);
+      kmm_free(peer->lc_cfps[peer->lc_cfpcount]);
+      peer->lc_cfps[peer->lc_cfpcount] = NULL;
+    }

Review Comment:
   ```suggestion
     while (count-- > 0)
       {
         file_close(conn->lc_cfps[--conn->lc_cfpcount]);
         kmm_free(conn->lc_cfps[conn->lc_cfpcount]);
         conn->lc_cfps[conn->lc_cfpcount] = NULL;
       }
   ```



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