Fix unref of GSource objects to address performance degradation

This commit is contained in:
Daniel P. Berrange 2010-12-14 12:47:29 +00:00
parent 938e008c19
commit 4043c332a0
2 changed files with 48 additions and 1 deletions

View File

@ -0,0 +1,42 @@
commit 968968c9cf705f5bc96764399ea17a27a454c1c5
Author: Daniel P. Berrange <berrange@redhat.com>
Date: Tue Dec 14 12:41:01 2010 +0000
Fix leak of GSource objects which causes performance problems
The GLib event loop scales poorly as the number of GSource objects
increases. A missing unref on the GSource objects used in the VNC
connection meant that many unused instances accumulated, slowing
down the event loop processing.
* src/vncconnection.c: Unref all GSource objects
diff --git a/src/vncconnection.c b/src/vncconnection.c
index 165a5f1..51b8b8d 100644
--- a/src/vncconnection.c
+++ b/src/vncconnection.c
@@ -234,6 +234,7 @@ static GIOCondition g_io_wait(GSocket *sock, GIOCondition cond)
g_source_set_callback(src, (GSourceFunc)g_io_wait_helper, coroutine_self(), NULL);
g_source_attach(src, NULL);
ret = coroutine_yield(NULL);
+ g_source_unref(src);
return *ret;
}
@@ -254,6 +255,7 @@ static GIOCondition g_io_wait_interruptable(struct wait_queue *wait,
id = g_source_attach(src, NULL);
wait->waiting = TRUE;
ret = coroutine_yield(NULL);
+ g_source_unref(src);
wait->waiting = FALSE;
if (ret == NULL) {
@@ -334,6 +336,8 @@ static gboolean g_condition_wait(g_condition_wait_func func, gpointer data)
g_source_attach(src, NULL);
g_source_set_callback(src, g_condition_wait_helper, coroutine_self(), NULL);
coroutine_yield(NULL);
+ g_source_unref(src);
+
return TRUE;
}

View File

@ -18,7 +18,7 @@
Summary: A GTK2 widget for VNC clients
Name: gtk-vnc
Version: 0.4.2
Release: 3%{?dist}%{?extra_release}
Release: 4%{?dist}%{?extra_release}
License: LGPLv2+
Group: Development/Libraries
Source: http://ftp.gnome.org/pub/GNOME/sources/%{name}/0.4/%{name}-%{version}.tar.bz2
@ -26,6 +26,7 @@ Patch1: %{name}-%{version}-motion-event-crash.patch
Patch2: %{name}-%{version}-tls-shutdown-crash.patch
Patch3: %{name}-%{version}-framebuffer-update-bounds-check.patch
Patch4: %{name}-%{version}-pixmap-cache.patch
Patch5: %{name}-%{version}-source-unref.patch
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
URL: http://live.gnome.org/gtk-vnc
BuildRequires: gtk2-devel >= 2.14
@ -154,6 +155,7 @@ cd %{name}-%{version}
%patch2 -p1
%patch3 -p1
%patch4 -p1
%patch5 -p1
cd ..
%if %{with_gtk3}
cp -a gtk-vnc-%{version} gtk-vnc2-%{version}
@ -299,6 +301,9 @@ rm -fr %{buildroot}
%changelog
* Tue Dec 14 2010 Daniel P. Berrange <berrange@redhat.com> - 0.4.2-4
- Fix unref of GSource objects to address performance degradation (rhbz #657847)
* Mon Nov 29 2010 Daniel P. Berrange <berrange@redhat.com> - 0.4.2-3
- Re-introduce a server side pixmap via cairo to cache framebuffer (rhbz #657542)