Commit 6f029c3e authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

Still try to splice as many memory pages as possible

parent 77cb7de9
...@@ -83,7 +83,7 @@ static void *Thread (void *data) ...@@ -83,7 +83,7 @@ static void *Thread (void *data)
stream_t *stream = data; stream_t *stream = data;
stream_sys_t *p_sys = stream->p_sys; stream_sys_t *p_sys = stream->p_sys;
#ifdef __linux__ #ifdef __linux__
uintptr_t page_mask = sysconf (_SC_PAGE_SIZE) - 1; ssize_t page_mask = sysconf (_SC_PAGE_SIZE) - 1;
#endif #endif
int fd = p_sys->write_fd; int fd = p_sys->write_fd;
bool error = false; bool error = false;
...@@ -108,14 +108,16 @@ static void *Thread (void *data) ...@@ -108,14 +108,16 @@ static void *Thread (void *data)
for (ssize_t i = 0, j; i < len; i += j) for (ssize_t i = 0, j; i < len; i += j)
{ {
struct iovec iov[1] = { { buf + i, len - i, } };
#ifdef __linux__ #ifdef __linux__
if (((len | i) & page_mask) == 0) if ((len - i) <= page_mask) /* incomplete last page */
j = vmsplice (fd, iov, 1, SPLICE_F_GIFT); j = write (fd, buf + i, len - i);
else else
{
struct iovec iov = { buf + i, (len - i) & ~page_mask, };
j = vmsplice (fd, &iov, 1, SPLICE_F_GIFT);
}
#else #else
j = writev (fd, iov, 1); j = write (fd, buf + i, len - i);
#endif #endif
if (j <= 0) if (j <= 0)
{ {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment