You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by gu...@apache.org on 2021/05/14 01:33:23 UTC

[incubator-nuttx] 02/05: fs: nfs: Fix to read a large packet in TCP mode

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

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

commit 2873f33bc455bea4d0a4ed49d0f206a5020eec64
Author: Masayuki Ishikawa <ma...@gmail.com>
AuthorDate: Wed May 12 07:09:52 2021 +0900

    fs: nfs: Fix to read a large packet in TCP mode
    
    Summary:
    - I noticed that receiving a read large packet (e.g. 2KB) in TCP
      mode does not work correctly
    - Actually, rpcclnt_receive() only received up to MSS
    - This commit fixes this issue
    
    Impact:
    - TCP mode only
    
    Testing:
    - Tested with Ubuntu 18.04 (x86_64)
    - Tested with spresense:rndis (defconfig will be updated later)
    
    Signed-off-by: Masayuki Ishikawa <Ma...@jp.sony.com>
---
 fs/nfs/rpc_clnt.c | 17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)

diff --git a/fs/nfs/rpc_clnt.c b/fs/nfs/rpc_clnt.c
index 9357966..46ee90b 100644
--- a/fs/nfs/rpc_clnt.c
+++ b/fs/nfs/rpc_clnt.c
@@ -359,6 +359,7 @@ static int rpcclnt_receive(FAR struct rpcclnt *rpc,
 {
   uint32_t mark;
   int error = 0;
+  int offset = 0;
 
   /* Receive the record marking(RM) for stream only */
 
@@ -388,12 +389,20 @@ static int rpcclnt_receive(FAR struct rpcclnt *rpc,
       resplen = mark;
     }
 
-  error = psock_recv(&rpc->rc_so, reply, resplen, 0);
-  if (error < 0)
+  do
     {
-      ferr("ERROR: psock_recv response failed: %d\n", error);
-      return error;
+      error = psock_recv(&rpc->rc_so, reply + offset, resplen, 0);
+
+      if (error < 0)
+        {
+          ferr("ERROR: psock_recv response failed: %d\n", error);
+          return error;
+        }
+
+      resplen -= error;
+      offset  += error;
     }
+  while (rpc->rc_sotype == SOCK_STREAM && resplen != 0);
 
   return OK;
 }