diff options
author | Chris Dickens <christopher.a.dickens@gmail.com> | 2013-06-14 10:54:29 -0700 |
---|---|---|
committer | Hans de Goede <hdegoede@redhat.com> | 2013-06-17 08:41:44 +0200 |
commit | 672ddae8ca26bb52378c74d1730f533593380727 (patch) | |
tree | 3a956bcea7ef38f60269527f44180a6b3d697a8f | |
parent | d8c714207df93d2f0d121520c5f2f81efc1f9431 (diff) | |
download | libusb-672ddae8ca26bb52378c74d1730f533593380727.tar.gz |
POSIX: Set usbi_pipe to non-blocking by oring O_NONBLOCK to fd flags.
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
-rw-r--r-- | libusb/os/poll_posix.c | 16 | ||||
-rw-r--r-- | libusb/version_nano.h | 2 |
2 files changed, 14 insertions, 4 deletions
diff --git a/libusb/os/poll_posix.c b/libusb/os/poll_posix.c index bd1c538..eeaf5dc 100644 --- a/libusb/os/poll_posix.c +++ b/libusb/os/poll_posix.c @@ -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; } diff --git a/libusb/version_nano.h b/libusb/version_nano.h index 1703d21..75ec58f 100644 --- a/libusb/version_nano.h +++ b/libusb/version_nano.h @@ -1 +1 @@ -#define LIBUSB_NANO 10739 +#define LIBUSB_NANO 10740 |