From ed37970a0405b5681bcd6449d4dc1b4f9080c4fa Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Tue, 3 May 2011 09:52:10 -0400 Subject: g_unix_set_fd_nonblocking: New API to control file descriptor blocking state And use it in relevant places in GLib. https://bugzilla.gnome.org/show_bug.cgi?id=649225 --- gio/gcancellable.c | 27 +++++---------------------- 1 file changed, 5 insertions(+), 22 deletions(-) (limited to 'gio/gcancellable.c') diff --git a/gio/gcancellable.c b/gio/gcancellable.c index c37baff51..32f508118 100644 --- a/gio/gcancellable.c +++ b/gio/gcancellable.c @@ -21,11 +21,10 @@ */ #include "config.h" -#ifdef HAVE_UNISTD_H -#include +#include "glib.h" +#ifdef G_OS_UNIX +#include "glib-unix.h" #endif -#include -#include #include #ifdef G_OS_WIN32 #include @@ -193,22 +192,6 @@ g_cancellable_class_init (GCancellableClass *klass) } #ifndef G_OS_WIN32 -static void -set_fd_nonblocking (int fd) -{ -#ifdef F_GETFL - glong fcntl_flags; - fcntl_flags = fcntl (fd, F_GETFL); - -#ifdef O_NONBLOCK - fcntl_flags |= O_NONBLOCK; -#else - fcntl_flags |= O_NDELAY; -#endif - - fcntl (fd, F_SETFL, fcntl_flags); -#endif -} static void set_fd_close_exec (int fd) @@ -235,8 +218,8 @@ g_cancellable_open_pipe (GCancellable *cancellable) /* Make them nonblocking, just to be sure we don't block * on errors and stuff */ - set_fd_nonblocking (priv->cancel_pipe[0]); - set_fd_nonblocking (priv->cancel_pipe[1]); + g_unix_set_fd_nonblocking (priv->cancel_pipe[0], TRUE, NULL); + g_unix_set_fd_nonblocking (priv->cancel_pipe[1], TRUE, NULL); set_fd_close_exec (priv->cancel_pipe[0]); set_fd_close_exec (priv->cancel_pipe[1]); -- cgit v1.2.1