Use g_cancellable_release_fd()
authorBenjamin Otte <otte@gnome.org>
Tue, 11 Aug 2009 13:12:20 +0000 (15:12 +0200)
committerBenjamin Otte <otte@gnome.org>
Wed, 19 Aug 2009 09:02:06 +0000 (11:02 +0200)
Part of: BugĀ 591388 - number of GCancellables available is too limited

gio/gsocket.c
gio/gunixinputstream.c
gio/gunixoutputstream.c

index 923212b..e216bd0 100644 (file)
@@ -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);
index a6038b8..b061c74 100644 (file)
@@ -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;
index 1680cd3..4ba581b 100644 (file)
@@ -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)
        {