GUnix{Input,Output}Stream: Only release cancelable poll-fd if we allocated it
authorDavid Zeuthen <davidz@redhat.com>
Mon, 5 Mar 2012 17:57:32 +0000 (12:57 -0500)
committerDavid Zeuthen <davidz@redhat.com>
Mon, 5 Mar 2012 18:00:28 +0000 (13:00 -0500)
Otherwise we get criticals a'la

 GLib-GIO-CRITICAL **: g_cancellable_release_fd: assertion `cancellable->priv->fd_refcount > 0' failed

when reading/writing to certain kinds of file descriptors.

Patch reviewed by Dan Winship on IRC.

Signed-off-by: David Zeuthen <davidz@redhat.com>
gio/gunixinputstream.c
gio/gunixoutputstream.c

index 3d5f938..65a0dbd 100644 (file)
@@ -417,7 +417,8 @@ g_unix_input_stream_read (GInputStream  *stream,
       break;
     }
 
-  g_cancellable_release_fd (cancellable);
+  if (nfds == 2)
+    g_cancellable_release_fd (cancellable);
   return res;
 }
 
index 01c3259..86f5277 100644 (file)
@@ -403,7 +403,8 @@ g_unix_output_stream_write (GOutputStream  *stream,
       break;
     }
 
-  g_cancellable_release_fd (cancellable);
+  if (nfds == 2)
+    g_cancellable_release_fd (cancellable);
   return res;
 }