From a36430c8db83efa088b229a7b48e4248e78e187f Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Thu, 18 Apr 2024 13:26:27 +0930 Subject: [PATCH] ccan/io/fdpass: tell caller that fd recv failed if they enabled extended errors Signed-off-by: Rusty Russell --- ccan/io/fdpass/fdpass.c | 4 +++- ccan/io/fdpass/fdpass.h | 5 +++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/ccan/io/fdpass/fdpass.c b/ccan/io/fdpass/fdpass.c index 63c46223..e002ddc1 100644 --- a/ccan/io/fdpass/fdpass.c +++ b/ccan/io/fdpass/fdpass.c @@ -39,7 +39,9 @@ static int do_fd_recv(int fd, struct io_plan_arg *arg) /* In case ccan/io ever gets smart with non-blocking. */ if (errno == EAGAIN || errno == EWOULDBLOCK) return 0; - return -1; + /* If they can't handle the error, this will close conn! */ + if (!io_get_extended_errors()) + return -1; } *(int *)arg->u1.vp = fdin; return 1; diff --git a/ccan/io/fdpass/fdpass.h b/ccan/io/fdpass/fdpass.h index 533bc840..9cdfa2c0 100644 --- a/ccan/io/fdpass/fdpass.h +++ b/ccan/io/fdpass/fdpass.h @@ -45,8 +45,9 @@ struct io_plan *io_send_fd_(struct io_conn *conn, * @arg: @next argument * * This creates a plan to receive a file descriptor, as sent by - * io_send_fd. Once it's all read, the @next function will be called: - * on an error, the finish function is called instead. + * io_send_fd. Once it's all read, the @next function will be called. + * On an error, if io_get_extended_errors() is true, then @next is called + * and @fd will be -1, otherwise the finish function is called. * * Note that the I/O may actually be done immediately. * -- 2.39.5