[glib] Use g_cancellable_release_fd()



commit faae032ad0579acf756e8848ebedbfda69d5b3be
Author: Benjamin Otte <otte gnome org>
Date:   Tue Aug 11 15:12:20 2009 +0200

    Use g_cancellable_release_fd()
    
    Part of: Bug 591388 - number of GCancellables available is too limited

 gio/gsocket.c           |   10 +++++++++-
 gio/gunixinputstream.c  |    3 ++-
 gio/gunixoutputstream.c |    1 +
 3 files changed, 12 insertions(+), 2 deletions(-)
---
diff --git a/gio/gsocket.c b/gio/gsocket.c
index 923212b..e216bd0 100644
--- a/gio/gsocket.c
+++ b/gio/gsocket.c
@@ -2255,7 +2255,10 @@ winsock_finalize (GSource *source)
   g_object_unref (socket);
 
   if (winsock_source->cancellable)
-    g_object_unref (winsock_source->cancellable);
+    {
+      g_cancellable_release_fd (winsock_source->cancellable);
+      g_object_unref (winsock_source->cancellable);
+    }
 }
 
 static GSourceFuncs winsock_funcs =
@@ -2470,6 +2473,8 @@ g_socket_condition_wait (GSocket       *socket,
 	current_condition = update_condition (socket);
       }
     remove_condition_watch (socket, &condition);
+    if (num_events > 1)
+      g_cancellable_release_fd (cancellable);
 
     return (condition & current_condition) != 0;
   }
@@ -2489,6 +2494,9 @@ g_socket_condition_wait (GSocket       *socket,
     do
       result = g_poll (poll_fd, num, -1);
     while (result == -1 && get_socket_errno () == EINTR);
+    
+    if (num > 1)
+      g_cancellable_release_fd (cancellable);
 
     return cancellable == NULL ||
       !g_cancellable_set_error_if_cancelled (cancellable, error);
diff --git a/gio/gunixinputstream.c b/gio/gunixinputstream.c
index a6038b8..b061c74 100644
--- a/gio/gunixinputstream.c
+++ b/gio/gunixinputstream.c
@@ -347,7 +347,8 @@ g_unix_input_stream_read (GInputStream  *stream,
       do
 	poll_ret = g_poll (poll_fds, 2, -1);
       while (poll_ret == -1 && errno == EINTR);
-      
+      g_cancellable_release_fd (cancellable);
+
       if (poll_ret == -1)
 	{
           int errsv = errno;
diff --git a/gio/gunixoutputstream.c b/gio/gunixoutputstream.c
index 1680cd3..4ba581b 100644
--- a/gio/gunixoutputstream.c
+++ b/gio/gunixoutputstream.c
@@ -333,6 +333,7 @@ g_unix_output_stream_write (GOutputStream  *stream,
       do
 	poll_ret = g_poll (poll_fds, 2, -1);
       while (poll_ret == -1 && errno == EINTR);
+      g_cancellable_release_fd (cancellable);
       
       if (poll_ret == -1)
 	{



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]