aboutsummaryrefslogtreecommitdiff
path: root/libbb
diff options
context:
space:
mode:
Diffstat (limited to 'libbb')
-rw-r--r--libbb/copyfd.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/libbb/copyfd.c b/libbb/copyfd.c
index dd0517cd6..3b754efb8 100644
--- a/libbb/copyfd.c
+++ b/libbb/copyfd.c
@@ -18,7 +18,7 @@
18 * was seen to cause largish delays when user tries to ^C a file copy. 18 * was seen to cause largish delays when user tries to ^C a file copy.
19 * Let's use a saner size. 19 * Let's use a saner size.
20 * Note: needs to be >= max(CONFIG_FEATURE_COPYBUF_KB), 20 * Note: needs to be >= max(CONFIG_FEATURE_COPYBUF_KB),
21 * or else "copy to eof" code will use neddlesly short reads. 21 * or else "copy to eof" code will use needlesly short reads.
22 */ 22 */
23#define SENDFILE_BIGBUF (16*1024*1024) 23#define SENDFILE_BIGBUF (16*1024*1024)
24 24
@@ -60,10 +60,13 @@ static off_t bb_full_fd_action(int src_fd, int dst_fd, off_t size)
60 ssize_t rd; 60 ssize_t rd;
61 61
62 if (sendfile_sz) { 62 if (sendfile_sz) {
63 rd = sendfile(dst_fd, src_fd, NULL, 63 /* dst_fd == -1 is a fake, else... */
64 size > sendfile_sz ? sendfile_sz : size); 64 if (dst_fd >= 0) {
65 if (rd >= 0) 65 rd = sendfile(dst_fd, src_fd, NULL,
66 goto read_ok; 66 size > sendfile_sz ? sendfile_sz : size);
67 if (rd >= 0)
68 goto read_ok;
69 }
67 sendfile_sz = 0; /* do not try sendfile anymore */ 70 sendfile_sz = 0; /* do not try sendfile anymore */
68 } 71 }
69#if CONFIG_FEATURE_COPYBUF_KB > 4 72#if CONFIG_FEATURE_COPYBUF_KB > 4