Skip to content

Commit 729507d

Browse files
pcd1193182behlendorf
authored andcommitted
Fix occasional rsend test crashes
We have occasional crashes in the rsend tests. Debugging revealed that this is because the send_worker thread is getting EINTR from splice(). This happens when a non-fatal signal is received during the syscall. We should retry the syscall, rather than exiting failure. Tweak the loop to only break if the splice is finished or we receive a non-EINTR error. Reviewed-by: Brian Behlendorf <[email protected]> Reviewed-by: Ahelenia Ziemiańska <[email protected]> Signed-off-by: Paul Dagnelie <[email protected]> Closes #15273
1 parent 3af6368 commit 729507d

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

lib/libzfs_core/libzfs_core.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -650,10 +650,12 @@ send_worker(void *arg)
650650
unsigned int bufsiz = max_pipe_buffer(ctx->from);
651651
ssize_t rd;
652652

653-
while ((rd = splice(ctx->from, NULL, ctx->to, NULL, bufsiz,
654-
SPLICE_F_MOVE | SPLICE_F_MORE)) > 0)
655-
;
656-
653+
for (;;) {
654+
rd = splice(ctx->from, NULL, ctx->to, NULL, bufsiz,
655+
SPLICE_F_MOVE | SPLICE_F_MORE);
656+
if ((rd == -1 && errno != EINTR) || rd == 0)
657+
break;
658+
}
657659
int err = (rd == -1) ? errno : 0;
658660
close(ctx->from);
659661
return ((void *)(uintptr_t)err);

0 commit comments

Comments
 (0)