mirror of
https://github.com/apache/nuttx.git
synced 2026-10-23 23:08:44 +00:00
libc/sendfile: fix lib_sendfile() partial send
MIRTOS-482 Fixing the behavior of sending only a few bytes of a file Signed-off-by: Peter Bee <bijunda1@xiaomi.com> Change-Id: Ieae600028b79794ede3ac576c2cd015d8df58b05
This commit is contained in:
parent
48b129f412
commit
487101234b
1 changed files with 13 additions and 5 deletions
|
|
@ -150,7 +150,13 @@ ssize_t sendfile(int outfd, int infd, off_t *offset, size_t count)
|
|||
{
|
||||
/* Read a buffer of data from the infd */
|
||||
|
||||
nbytesread = _NX_READ(infd, iobuffer, CONFIG_LIB_SENDFILE_BUFSIZE);
|
||||
nbytesread = count - ntransferred;
|
||||
if (nbytesread > CONFIG_LIB_SENDFILE_BUFSIZE)
|
||||
{
|
||||
nbytesread = CONFIG_LIB_SENDFILE_BUFSIZE;
|
||||
}
|
||||
|
||||
nbytesread = _NX_READ(infd, iobuffer, nbytesread);
|
||||
|
||||
/* Check for end of file */
|
||||
|
||||
|
|
@ -210,15 +216,17 @@ ssize_t sendfile(int outfd, int infd, off_t *offset, size_t count)
|
|||
|
||||
if (nbyteswritten >= 0)
|
||||
{
|
||||
/* Advance the buffer pointer and decrement the number of bytes
|
||||
* remaining in the iobuffer. Typically, nbytesread will now
|
||||
* be zero.
|
||||
/* Advance the buffer pointer and decrement the number of
|
||||
* bytes remaining in the iobuffer. Typically, nbytesread
|
||||
* will now be zero.
|
||||
*/
|
||||
|
||||
wrbuffer += nbyteswritten;
|
||||
nbytesread -= nbyteswritten;
|
||||
|
||||
/* Increment the total number of bytes successfully transferred. */
|
||||
/* Increment the total number of bytes successfully
|
||||
* transferred.
|
||||
*/
|
||||
|
||||
ntransferred += nbyteswritten;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue