From 1bddcf3dd72fe3924b8ad473579daeb922dbf669 Mon Sep 17 00:00:00 2001 From: Stefano Brivio Date: Tue, 19 Oct 2021 09:19:50 +0200 Subject: tcp: Fix for non-blocking splice() on older kernels For some reason, on 4.19, splice() doesn't honour SOCK_NONBLOCK from accept4() while reading from a TCP socket. Pass SPLICE_F_NONBLOCK explicitly in all cases. Signed-off-by: Stefano Brivio --- tcp.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tcp.c') diff --git a/tcp.c b/tcp.c index 3542827..0093ec4 100644 --- a/tcp.c +++ b/tcp.c @@ -3075,7 +3075,7 @@ swap: retry: read = splice(move_from, NULL, pipes[1], NULL, c->tcp.pipe_size, - SPLICE_F_MOVE); + SPLICE_F_MOVE | SPLICE_F_NONBLOCK); if (read < 0) { if (errno == EINTR) goto retry; @@ -3099,7 +3099,7 @@ retry: eintr: written = splice(pipes[0], NULL, move_to, NULL, to_write, - SPLICE_F_MOVE | more); + SPLICE_F_MOVE | more | SPLICE_F_NONBLOCK); /* Most common case: skip updating counters. */ if (read > 0 && read == written) { -- cgit v1.2.3