POSIX: Set usbi_pipe to non-blocking by oring O_NONBLOCK to fd flags.
authorChris Dickens <christopher.a.dickens@gmail.com>
Fri, 14 Jun 2013 17:54:29 +0000 (10:54 -0700)
committerHans de Goede <hdegoede@redhat.com>
Mon, 17 Jun 2013 06:41:44 +0000 (08:41 +0200)
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
libusb/os/poll_posix.c
libusb/version_nano.h

index bd1c5388e7fc0be4b039769271b7f3b8527078ae..eeaf5dce49fca5763935619b1c3123dbbb90545e 100644 (file)
@@ -31,11 +31,21 @@ int usbi_pipe(int pipefd[2])
        if (ret != 0) {
                return ret;
        }
-       ret = fcntl(pipefd[1], F_SETFD, O_NONBLOCK);
+       ret = fcntl(pipefd[1], F_GETFL);
+       if (ret == -1) {
+               usbi_dbg("Failed to get pipe fd flags: %d", errno);
+               goto err_close_pipe;
+       }
+       ret = fcntl(pipefd[1], F_SETFL, ret | O_NONBLOCK);
        if (ret != 0) {
                usbi_dbg("Failed to set non-blocking on new pipe: %d", errno);
-               usbi_close(pipefd[0]);
-               usbi_close(pipefd[1]);
+               goto err_close_pipe;
        }
+
+       return 0;
+
+err_close_pipe:
+       usbi_close(pipefd[0]);
+       usbi_close(pipefd[1]);
        return ret;
 }
index 1703d211a7aa0110fb7748ecc399a363c722b3e9..75ec58f73d156401dc1331744f12a924c2b4e094 100644 (file)
@@ -1 +1 @@
-#define LIBUSB_NANO 10739
+#define LIBUSB_NANO 10740