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

   ## Summary
   
   If `sendfile()` is called with a zero count, it will nevertheless try to 
send the data.
   This is mostly meaningless, it causes waste of resources, and in some cases 
delays.
   
   For example, in case of just copying a file [unneeded buffers are 
allocated](https://github.com/apache/nuttx/blob/master/fs/vfs/fs_sendfile.c#L74),
 or in case of TCP the code waits for (no) data to be transmitted [till the 
socket 
timeouts](https://github.com/apache/nuttx/blob/master/net/tcp/tcp_sendfile.c#L527).
   
   This commit adds special handling for this case, allowing `sendfile()` to 
return immediately zero.  
   The new behavior is in line with the Linux variant of `sendfile()`, as 
tested with 
[this](https://github.com/fjpanag/code_for_nuttx/blob/main/ftp/ftpc.c) FTP 
client.
   
   For more information, see the discussion 
[here](https://lists.apache.org/thread/gls3rr8h4ggbwgk4skq1j0txoyd94jrf).
   
   ## Impact
   
   Proper handling of this edge case, without waste of resources, or needless 
delays.
   
   ## Testing
   
   *Pending. I will comment back when this is tested on actual hardware.*
   
   


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to