io: fix io_connect().
authorRusty Russell <rusty@rustcorp.com.au>
Thu, 17 Jul 2014 03:39:55 +0000 (13:09 +0930)
committerRusty Russell <rusty@rustcorp.com.au>
Thu, 17 Jul 2014 03:39:55 +0000 (13:09 +0930)
How embarrassing: we weren't actually doing a non-blocking connect because
I was using F_SETFD instead of F_SETFL...

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
ccan/io/io.c

index 3f618249d279d260d77c60aa8ac1c87645a0378b..bac08c9f9effd984c6297da04af9211d2e5c8ba3 100644 (file)
@@ -403,8 +403,8 @@ struct io_plan io_connect_(int fd, const struct addrinfo *addr,
        plan.next_arg = arg;
 
        /* Save old flags, set nonblock if not already. */
-       plan.u1.s = fcntl(fd, F_GETFD);
-       fcntl(fd, F_SETFD, plan.u1.s | O_NONBLOCK);
+       plan.u1.s = fcntl(fd, F_GETFL);
+       fcntl(fd, F_SETFL, plan.u1.s | O_NONBLOCK);
 
        /* Immediate connect can happen. */
        if (connect(fd, addr->ai_addr, addr->ai_addrlen) == 0) {