]> git.ozlabs.org Git - ccan/commitdiff
ccan/io/fdpass: tell caller that fd recv failed if they enabled extended errors
authorRusty Russell <rusty@rustcorp.com.au>
Thu, 18 Apr 2024 03:56:27 +0000 (13:26 +0930)
committerRusty Russell <rusty@rustcorp.com.au>
Mon, 24 Jun 2024 02:46:26 +0000 (12:16 +0930)
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
ccan/io/fdpass/fdpass.c
ccan/io/fdpass/fdpass.h

index 63c46223691311f7db2eade98c961face21d4b34..e002ddc1f6aadcd3e314d38b135f611dc6137257 100644 (file)
@@ -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;
index 533bc840f7ba5fbb03af6979032c9674b906d701..9cdfa2c02eef63616754e61695867e136b813680 100644 (file)
@@ -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.
  *