network socket receive splice size

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Ezra Kissel
Date: Friday, June 20, 2008 - 12:04 pm

I am using the splice syscall in kernel 2.6.25.4 with network socket 
receive to splice incoming and outgoing TCP sockets. I perform something 
like the following:

#define SPLICE_SIZE (12*1024)

int fd[2];
ret = pipe(fd);

ret = splice(src, NULL, fd[1], NULL, SPLICE_SIZE, SPLICE_F_MORE | 
SPLICE_F_MOVE);

bytes_left = ret;

while (bytes_left > 0) {
   ret = splice(fd[0], NULL, sink, NULL, bytes_left, SPLICE_F_NONBLOCK);
   bytes_left -= ret;
}

This works well when SPLICE_SIZE is around 12K or lower, but anything 
much more than that will cause the src splice call to block either right 
away or after a few iterations. It almost seems as though the pipe 
buffer is becoming full although I have used poll to check for both 
sockets and pipe fds before calling splice, and the sink splice call 
always sends the current number of bytes. I have also tried virtually 
all combinations of the SPLICE_F_ options without success. Has anyone 
run into a similar issue with socket-to-socket splicing and larger 
splice sizes? I would really like to use the full 64K splice size to and 
from the pipe.

I should mention that the splice test applications do work correctly 
with 64K splice sizes when splicing to/from a network socket(s) to 
STDOUT or STDIN. Any thoughts?
--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
network socket receive splice size, Ezra Kissel, (Fri Jun 20, 12:04 pm)