[sysprof/ftrace: 15/16] Skip over input bytes even when in the dead period.
- From: Søren Sandmann Pedersen <ssp src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [sysprof/ftrace: 15/16] Skip over input bytes even when in the dead period.
- Date: Fri, 14 Aug 2009 06:57:55 +0000 (UTC)
commit 1cb18feb0af94c716bbdb61d645d1529f19f03de
Author: Søren Sandmann Pedersen <sandmann daimi au dk>
Date: Fri Aug 14 02:44:24 2009 -0400
Skip over input bytes even when in the dead period.
Otherwise we can end up with broken half-read entries in the buffer.
TODO | 2 ++
collector.c | 41 ++++++++++++++++++++---------------------
2 files changed, 22 insertions(+), 21 deletions(-)
---
diff --git a/TODO b/TODO
index f39f7bd..97e3f5d 100644
--- a/TODO
+++ b/TODO
@@ -23,6 +23,8 @@ Before 1.0.4:
Before 1.2:
+* Rename sysprof-text to sysprof-cli
+
* Give an informative error message if run as root
* Find out why gtk_tree_view_columns_autosize() apparently doesn't
diff --git a/collector.c b/collector.c
index cecb2cf..62e0e92 100644
--- a/collector.c
+++ b/collector.c
@@ -365,32 +365,31 @@ on_read (gpointer data)
while ((n_bytes = read (collector->fd, input, sizeof (input))) > 0)
{
+ gboolean first_sample;
+ const guchar *s;
+ int len;
+
g_assert (data == collector);
-
- if (!in_dead_period (collector))
+
+ g_string_append_len (collector->input, input, n_bytes);
+
+ first_sample = collector->n_samples == 0;
+
+ len = collector->input->len;
+ s = (const guchar *)collector->input->str;
+ while (len >= sizeof (Entry))
{
- gboolean first_sample;
- const guchar *s;
- int len;
-
- g_string_append_len (collector->input, input, n_bytes);
-
- first_sample = collector->n_samples == 0;
-
- len = collector->input->len;
- s = (const guchar *)collector->input->str;
- while (len >= sizeof (Entry))
- {
+ if (!in_dead_period (collector))
process_entry (collector, (Entry *)s);
-
- len -= sizeof (Entry);
- s += sizeof (Entry);
- }
- g_string_erase (collector->input, 0, collector->input->len - len);
- if (collector->callback && collector->n_samples > 0)
- collector->callback (first_sample, collector->data);
+ len -= sizeof (Entry);
+ s += sizeof (Entry);
}
+
+ g_string_erase (collector->input, 0, collector->input->len - len);
+
+ if (collector->callback && collector->n_samples > 0)
+ collector->callback (first_sample, collector->data);
}
if (n_bytes == -1 && errno != EAGAIN)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]