aboutsummaryrefslogtreecommitdiff
path: root/networking
diff options
context:
space:
mode:
authorBartosz Golaszewski <bartekgola@gmail.com>2014-11-27 13:20:24 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2014-11-27 23:31:58 +0100
commit8d75d794ea505003fddea8e757d43976db8d6861 (patch)
tree0aae42250953ae1de36666aa5fc12a11ad3be02f /networking
parentee41094b809452fdd23d25c1879a96acfcddde08 (diff)
downloadbusybox-w32-8d75d794ea505003fddea8e757d43976db8d6861.tar.gz
busybox-w32-8d75d794ea505003fddea8e757d43976db8d6861.tar.bz2
busybox-w32-8d75d794ea505003fddea8e757d43976db8d6861.zip
libbb: use sendfile() to copy data between file descriptors
Busybox already uses sendfile in httpd. This patch proposes to use it globally to copy data between file descriptors. It speeds up the copying on slow systems a lot - below are the times needed to copy a 450Mb file with and without this option enabled on a BeagleBone Black: sendfile: user 0m0.000s sys 0m8.170s read/write 4k: user 0m0.470s sys 0m16.300s function old new delta bb_full_fd_action 394 474 +80 Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'networking')
-rw-r--r--networking/Config.src8
-rw-r--r--networking/httpd.c6
2 files changed, 3 insertions, 11 deletions
diff --git a/networking/Config.src b/networking/Config.src
index e56646917..15a696876 100644
--- a/networking/Config.src
+++ b/networking/Config.src
@@ -181,14 +181,6 @@ config FEATURE_HTTPD_RANGES
181 "Range: bytes=NNN-[MMM]" header. Allows for resuming interrupted 181 "Range: bytes=NNN-[MMM]" header. Allows for resuming interrupted
182 downloads, seeking in multimedia players etc. 182 downloads, seeking in multimedia players etc.
183 183
184config FEATURE_HTTPD_USE_SENDFILE
185 bool "Use sendfile system call"
186 default y
187 depends on HTTPD
188 help
189 When enabled, httpd will use the kernel sendfile() function
190 instead of read/write loop.
191
192config FEATURE_HTTPD_SETUID 184config FEATURE_HTTPD_SETUID
193 bool "Enable -u <user> option" 185 bool "Enable -u <user> option"
194 default y 186 default y
diff --git a/networking/httpd.c b/networking/httpd.c
index 621d9cddc..9cf080401 100644
--- a/networking/httpd.c
+++ b/networking/httpd.c
@@ -133,7 +133,7 @@
133# include <security/pam_appl.h> 133# include <security/pam_appl.h>
134# include <security/pam_misc.h> 134# include <security/pam_misc.h>
135#endif 135#endif
136#if ENABLE_FEATURE_HTTPD_USE_SENDFILE 136#if ENABLE_FEATURE_USE_SENDFILE
137# include <sys/sendfile.h> 137# include <sys/sendfile.h>
138#endif 138#endif
139/* amount of buffering in a pipe */ 139/* amount of buffering in a pipe */
@@ -1624,7 +1624,7 @@ static NOINLINE void send_file_and_exit(const char *url, int what)
1624#endif 1624#endif
1625 if (what & SEND_HEADERS) 1625 if (what & SEND_HEADERS)
1626 send_headers(HTTP_OK); 1626 send_headers(HTTP_OK);
1627#if ENABLE_FEATURE_HTTPD_USE_SENDFILE 1627#if ENABLE_FEATURE_USE_SENDFILE
1628 { 1628 {
1629 off_t offset = range_start; 1629 off_t offset = range_start;
1630 while (1) { 1630 while (1) {
@@ -1654,7 +1654,7 @@ static NOINLINE void send_file_and_exit(const char *url, int what)
1654 break; 1654 break;
1655 } 1655 }
1656 if (count < 0) { 1656 if (count < 0) {
1657 IF_FEATURE_HTTPD_USE_SENDFILE(fin:) 1657 IF_FEATURE_USE_SENDFILE(fin:)
1658 if (verbose > 1) 1658 if (verbose > 1)
1659 bb_perror_msg("error"); 1659 bb_perror_msg("error");
1660 } 1660 }