sysprof r423 - branches/ftrace-branch



Author: ssp
Date: Sat May 10 21:54:44 2008
New Revision: 423
URL: http://svn.gnome.org/viewvc/sysprof?rev=423&view=rev

Log:
2008-05-10  Soren Sandmann Pedersen  <ssp localhost localdomain>

	* collector.c (on_read): Simplify the read routine



Modified:
   branches/ftrace-branch/ChangeLog
   branches/ftrace-branch/collector.c

Modified: branches/ftrace-branch/collector.c
==============================================================================
--- branches/ftrace-branch/collector.c	(original)
+++ branches/ftrace-branch/collector.c	Sat May 10 21:54:44 2008
@@ -583,29 +583,46 @@
     int n_bytes;
     gboolean first;
     int i;
-    static int n_reads;
 
     memset (input, '1', sizeof input);
-    
-    n_bytes = read (collector->fd, input, sizeof (input));
 
-    g_assert (data == collector);
+    while ((n_bytes = read (collector->fd, input, sizeof (input))) > 0)
+    {
+	g_assert (data == collector);
+
+	if (!in_dead_period (collector))
+	{
+	    g_string_append_len (collector->input, input, n_bytes);
+	    
+	    first = collector->n_samples == 0;
+
+	    parse_input (collector);
+	    
+	    if (collector->callback && collector->n_samples > 0)
+		collector->callback (first, collector->data);
+	}
+    }
+
+    if (n_bytes == -1 && errno != EAGAIN)
+    {
+	g_warning ("Read from trace pipe: %s\n", strerror (errno));
+    }
+
+
+
+    
     
+#if 0
     if (n_bytes <= 0)
     {
 	g_print ("result: %d\n", n_bytes);
 	return;
     }
 
-    n_reads++;
-    if (n_reads % 10000 == 0)
-	g_print ("%d reads\n", n_reads);
-    
     if (in_dead_period (collector))
 	return;
+#endif
     
-    first = collector->n_samples == 0;
-
 #if 0
     /* Sometimes we get nul bytes in the input. This is inconvenient, so
      * replace them with newlines.
@@ -617,12 +634,6 @@
     }
 #endif
     
-    g_string_append_len (collector->input, input, n_bytes);
-
-    parse_input (collector);
-    
-    if (collector->callback && collector->n_samples > 0)
-	collector->callback (first, collector->data);
 }
 
 static gboolean



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