[telepathy-idle/f19] Pull upstream patches to fix 100% cpu usage. (#902075)
Brian Pepple
bpepple at fedoraproject.org
Mon Oct 14 13:43:11 UTC 2013
commit d1910335da7f6fbf62912f980c9ca25f53e01533
Author: Brian Pepple <bpepple at fedoraproject.org>
Date: Mon Oct 14 09:42:49 2013 -0400
Pull upstream patches to fix 100% cpu usage. (#902075)
001-kill_async_read_when_disconnecting.patch | 58 ++++++++++++++++++++++++++
002-dispose_internal_objects.patch | 29 +++++++++++++
telepathy-idle.spec | 9 ++++-
3 files changed, 95 insertions(+), 1 deletions(-)
---
diff --git a/001-kill_async_read_when_disconnecting.patch b/001-kill_async_read_when_disconnecting.patch
new file mode 100644
index 0000000..bb47def
--- /dev/null
+++ b/001-kill_async_read_when_disconnecting.patch
@@ -0,0 +1,58 @@
+From 42fd234c2336718a93993829c4d55c819b172012 Mon Sep 17 00:00:00 2001
+From: Lionel Landwerlin <llandwerlin at gmail.com>
+Date: Thu, 29 Aug 2013 22:48:10 +0000
+Subject: ServerConnection: kill async read when disconnecting
+
+GSocket creates GSources to provide GInputStream and GOutputStream
+objects. Interestingly, it doesn't set the GIOCondition on the GSource
+to handle G_IO_NVAL (ie. your file descriptor is not valid anymore).
+
+It means that if your trying to read asynchronously from the socket
+while someone else closes the socket, you end with an GInputStream
+that can never complete its asynchronous read operation because the
+file descriptor isn't valid anymore but that isn't a condition to
+dispatch the GSource and end the asynchronous read with an error.
+Alternatively, this wakes up the gmainloop all the time => 100% cpu
+consumption.
+
+Bug: https://bugs.freedesktop.org/show_bug.cgi?id=64923
+Reviewed-by: Simon McVittie <simon.mcvittie at collabora.co.uk>
+---
+diff --git a/src/idle-server-connection.c b/src/idle-server-connection.c
+index b593fa3..a921c33 100644
+--- a/src/idle-server-connection.c
++++ b/src/idle-server-connection.c
+@@ -71,6 +71,7 @@ struct _IdleServerConnectionPrivate {
+
+ GSocketClient *socket_client;
+ GIOStream *io_stream;
++ GCancellable *read_cancellable;
+ GCancellable *cancellable;
+
+ IdleServerConnectionState state;
+@@ -245,8 +246,12 @@ static void change_state(IdleServerConnection *conn, IdleServerConnectionState s
+ static void _input_stream_read(IdleServerConnection *conn, GInputStream *input_stream, GAsyncReadyCallback callback) {
+ IdleServerConnectionPrivate *priv = IDLE_SERVER_CONNECTION_GET_PRIVATE(conn);
+
++ if (priv->read_cancellable == NULL)
++ priv->read_cancellable = g_cancellable_new ();
++
++
+ memset(priv->input_buffer, '\0', sizeof(priv->input_buffer));
+- g_input_stream_read_async (input_stream, &priv->input_buffer, sizeof(priv->input_buffer) - 1, G_PRIORITY_DEFAULT, NULL, callback, conn);
++ g_input_stream_read_async (input_stream, &priv->input_buffer, sizeof(priv->input_buffer) - 1, G_PRIORITY_DEFAULT, priv->read_cancellable, callback, conn);
+ }
+
+ static void _input_stream_read_ready(GObject *source_object, GAsyncResult *res, gpointer user_data) {
+@@ -514,6 +519,9 @@ void idle_server_connection_disconnect_full_async(IdleServerConnection *conn, gu
+
+ priv->reason = reason;
+
++ g_cancellable_cancel (priv->read_cancellable);
++ g_clear_object (&priv->read_cancellable);
++
+ result = g_simple_async_result_new(G_OBJECT(conn), callback, user_data, idle_server_connection_disconnect_full_async);
+ g_io_stream_close_async(priv->io_stream, G_PRIORITY_DEFAULT, cancellable, _close_ready, result);
+ g_object_unref(priv->io_stream);
+--
+cgit v0.9.0.2-2-gbebe
diff --git a/002-dispose_internal_objects.patch b/002-dispose_internal_objects.patch
new file mode 100644
index 0000000..32f3b6f
--- /dev/null
+++ b/002-dispose_internal_objects.patch
@@ -0,0 +1,29 @@
+From 983603a6db3b01e4a7d117ee35d20b60c0c896a4 Mon Sep 17 00:00:00 2001
+From: Lionel Landwerlin <llandwerlin at gmail.com>
+Date: Thu, 29 Aug 2013 22:48:36 +0000
+Subject: ServerConnection: dispose internal objects
+
+Bug: https://bugs.freedesktop.org/show_bug.cgi?id=64923
+Reviewed-by: Simon McVittie <simon.mcvittie at collabora.co.uk>
+---
+diff --git a/src/idle-server-connection.c b/src/idle-server-connection.c
+index a921c33..66fe3d0 100644
+--- a/src/idle-server-connection.c
++++ b/src/idle-server-connection.c
+@@ -107,10 +107,10 @@ static void idle_server_connection_dispose(GObject *obj) {
+ IdleServerConnection *conn = IDLE_SERVER_CONNECTION(obj);
+ IdleServerConnectionPrivate *priv = IDLE_SERVER_CONNECTION_GET_PRIVATE(conn);
+
+- if (priv->socket_client != NULL) {
+- g_object_unref(priv->socket_client);
+- priv->socket_client = NULL;
+- }
++ g_clear_object (&priv->socket_client);
++ g_clear_object (&priv->io_stream);
++ g_clear_object (&priv->tls_manager);
++ g_clear_object (&priv->read_cancellable);
+ }
+
+ static void idle_server_connection_finalize(GObject *obj) {
+--
+cgit v0.9.0.2-2-gbebe
diff --git a/telepathy-idle.spec b/telepathy-idle.spec
index 1fbe5e9..0066d63 100644
--- a/telepathy-idle.spec
+++ b/telepathy-idle.spec
@@ -6,13 +6,15 @@
Name: telepathy-idle
Version: 0.1.16
-Release: 1%{?dist}
+Release: 2%{?dist}
Summary: IRC connection manager for Telepathy
Group: Applications/Communications
License: LGPLv2+
URL: http://telepathy.freedesktop.org/wiki/FrontPage
Source0: http://telepathy.freedesktop.org/releases/%{name}/%{name}-%{version}.tar.gz
+Patch0: 001-kill_async_read_when_disconnecting.patch
+Patch1: 002-dispose_internal_objects.patch
BuildRequires: dbus-devel
BuildRequires: dbus-glib-devel
@@ -36,6 +38,8 @@ A full-featured IRC connection manager for the Telepathy project.
%prep
%setup -q
+%patch0 -p1 -b .async
+%patch1 -p1 -b .dispose
%if %{run_tests}
@@ -63,6 +67,9 @@ make install DESTDIR=$RPM_BUILD_ROOT
%changelog
+* Mon Oct 14 2013 Brian Pepple <bpepple at fedoraproject.org> - 0.1.16-2
+- Pull upstream patches to fix 100% cpu usage. (#902075)
+
* Wed May 1 2013 Brian Pepple <bpepple at fedoraproject.org> - 0.1.16-1
- Update to 0.1.16.
More information about the scm-commits
mailing list