{
static int pipefd[2] = { -1, -1 };
static bool try_splice_call = false;
+ static size_t chunk_size = 16384;
size_t total_written = 0;
loff_t splice_offset = offset;
count);
}
- if ((pipefd[0] == -1) && (pipe(pipefd) == -1)) {
- try_splice_call = false;
- return default_sys_recvfile(fromfd, tofd, offset, count);
+ if (pipefd[0] == -1) {
+ int ret;
+
+ ret = pipe(pipefd);
+ if (ret == -1) {
+ try_splice_call = false;
+ return default_sys_recvfile(fromfd, tofd, offset, count);
+ }
+
+#ifdef F_SETPIPE_SZ
+ fcntl(pipefd[1], F_SETPIPE_SZ, 1048576);
+ ret = fcntl(pipefd[1], F_GETPIPE_SZ);
+ if (ret > chunk_size) {
+ chunk_size = ret;
+ }
+#endif
}
while (count > 0) {
int nread, to_write;
nread = splice(fromfd, NULL, pipefd[1], NULL,
- MIN(count, 16384), SPLICE_F_MOVE);
+ MIN(count, chunk_size), SPLICE_F_MOVE);
if (nread == -1) {
if (errno == EINTR) {
continue;