[giggle] Improve responsiveness when executing git commands



commit fbc6b1962ea70bbe7b32e4bcfab92ed24ddfc769
Author: Florian Müllner <fmuellner src gnome org>
Date:   Wed Jan 27 01:34:27 2010 +0100

    Improve responsiveness when executing git commands
    
    Set G_IO_FLAG_NONBLOCK on the command's pipe to avoid I/O blocking.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=608264

 libgiggle/giggle-dispatcher.c |    7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)
---
diff --git a/libgiggle/giggle-dispatcher.c b/libgiggle/giggle-dispatcher.c
index c9e1e3f..bc3d691 100644
--- a/libgiggle/giggle-dispatcher.c
+++ b/libgiggle/giggle-dispatcher.c
@@ -186,6 +186,9 @@ dispatcher_start_job (GiggleDispatcher *dispatcher, DispatcherJob *job)
 
 	priv->channel = g_io_channel_unix_new (job->std_out);
 	g_io_channel_set_encoding (priv->channel, NULL, NULL);
+	g_io_channel_set_flags (priv->channel,
+	                        g_io_channel_get_flags (priv->channel)
+	                        | G_IO_FLAG_NONBLOCK, NULL);
 	priv->output = g_string_new ("");
 
 	priv->current_job = job;
@@ -356,16 +359,14 @@ dispatcher_job_read_cb (GIOChannel       *source,
 	GiggleDispatcherPriv *priv;
 	gsize                 length;
 	gchar                *str;
-	gint                  count = 0;
 	GIOStatus             status;
 	GError               *error = NULL;
 
 	priv = GET_PRIV (dispatcher);
 	status = G_IO_STATUS_NORMAL;
 
-	while (count < 10 && status == G_IO_STATUS_NORMAL) {
+	while (status == G_IO_STATUS_NORMAL) {
 		status = g_io_channel_read_line (source, &str, &length, NULL, &error);
-		count++;
 
 		if (str) {
 			g_string_append_len (priv->output, str, length);



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