From 6e8caec6d9af06d4f7f0e6cd1a86c6c47e49ff01 Mon Sep 17 00:00:00 2001 From: David Zeuthen Date: Mon, 5 Mar 2012 12:57:32 -0500 Subject: [PATCH] GUnix{Input,Output}Stream: Only release cancelable poll-fd if we allocated it 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 --- gio/gunixinputstream.c | 3 ++- gio/gunixoutputstream.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/gio/gunixinputstream.c b/gio/gunixinputstream.c index 3d5f93806..65a0dbdca 100644 --- a/gio/gunixinputstream.c +++ b/gio/gunixinputstream.c @@ -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; } diff --git a/gio/gunixoutputstream.c b/gio/gunixoutputstream.c index 01c32591e..86f527777 100644 --- a/gio/gunixoutputstream.c +++ b/gio/gunixoutputstream.c @@ -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; }