[gtk-vnc] Fix leak of GSource objects which causes performance problems



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

 src/vncconnection.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
---
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;
 }
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]