From: Chris Dickens Date: Fri, 14 Jun 2013 17:54:29 +0000 (-0700) Subject: POSIX: Set usbi_pipe to non-blocking by oring O_NONBLOCK to fd flags. X-Git-Tag: upstream/1.0.21~415 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=672ddae8ca26bb52378c74d1730f533593380727;p=platform%2Fupstream%2Flibusb.git POSIX: Set usbi_pipe to non-blocking by oring O_NONBLOCK to fd flags. Signed-off-by: Hans de Goede --- 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