[Spice-devel] [PATCH spice-server v2 1/2] red-channel: Initialize statistic node correctly
Frediano Ziglio
fziglio at redhat.com
Wed Mar 8 14:55:30 UTC 2017
The default memset(0) on the node does not init it correctly.
Do so to avoid other nodes/counters appended to unwanted nodes.
This is due to INVALID_STAT_REF being ~0. We could not change
this value easily as this is used as ABI for the statistics file.
Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
---
server/red-channel.c | 4 ++++
server/stat.h | 8 ++++++++
2 files changed, 12 insertions(+)
Changes since v1:
- improve comment;
- rename initialization function.
diff --git a/server/red-channel.c b/server/red-channel.c
index 8ae6ece..8e4d582 100644
--- a/server/red-channel.c
+++ b/server/red-channel.c
@@ -300,6 +300,10 @@ red_channel_init(RedChannel *self)
self->priv->client_cbs.connect = red_channel_client_default_connect;
self->priv->client_cbs.disconnect = red_channel_client_default_disconnect;
self->priv->client_cbs.migrate = red_channel_client_default_migrate;
+
+ /* this is necessary as invalid value is not all fields 0
+ * so the default memset(0) is not enough */
+ stat_node_set_invalid(&self->priv->stat);
}
diff --git a/server/stat.h b/server/stat.h
index 5255efa..33d6e90 100644
--- a/server/stat.h
+++ b/server/stat.h
@@ -70,6 +70,14 @@ stat_remove_counter(SpiceServer *reds, RedStatCounter *counter)
#endif /* RED_STATISTICS */
static inline void
+stat_node_set_invalid(G_GNUC_UNUSED RedStatNode *node)
+{
+#ifdef RED_STATISTICS
+ node->ref = INVALID_STAT_REF;
+#endif
+}
+
+static inline void
stat_inc_counter(RedStatCounter counter, uint64_t value)
{
#ifdef RED_STATISTICS
--
2.9.3
More information about the Spice-devel
mailing list