From faae032ad0579acf756e8848ebedbfda69d5b3be Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Tue, 11 Aug 2009 15:12:20 +0200 Subject: [PATCH] Use g_cancellable_release_fd() MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 923212ba..e216bd04 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 a6038b8c..b061c740 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 1680cd35..4ba581bd 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) { -- 2.34.1