summaryrefslogtreecommitdiffstats
path: root/common/glib-helper.c
diff options
context:
space:
mode:
authorMarcel Holtmann <marcel@holtmann.org>2008-05-08 18:47:21 +0000
committerMarcel Holtmann <marcel@holtmann.org>2008-05-08 18:47:21 +0000
commit4d39e4d2ea552e2d4ad36c085700f513e10be7e0 (patch)
tree49f9b22a972b09445eec7581b2d460bd0ee6189c /common/glib-helper.c
parentb5514e6c7f0258da455bbde02482fbcdb29d4442 (diff)
Move set_nonblocking() to the GLib helpers for now
Diffstat (limited to 'common/glib-helper.c')
-rw-r--r--common/glib-helper.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/common/glib-helper.c b/common/glib-helper.c
index 8fa8efcf..36228d45 100644
--- a/common/glib-helper.c
+++ b/common/glib-helper.c
@@ -43,6 +43,25 @@
#include "glib-helper.h"
+int set_nonblocking(int fd)
+{
+ long arg;
+
+ arg = fcntl(fd, F_GETFL);
+ if (arg < 0)
+ return -errno;
+
+ /* Return if already nonblocking */
+ if (arg & O_NONBLOCK)
+ return 0;
+
+ arg |= O_NONBLOCK;
+ if (fcntl(fd, F_SETFL, arg) < 0)
+ return -errno;
+
+ return 0;
+}
+
struct io_context {
GIOChannel *io;
bt_io_callback_t cb;