[Spice-commits] server/main-dispatcher.c server/tests
Frediano Ziglio
fziglio at kemper.freedesktop.org
Thu Mar 2 11:16:28 UTC 2017
server/main-dispatcher.c | 20 ++++++++++++++++----
server/tests/test-leaks.c | 1 +
2 files changed, 17 insertions(+), 4 deletions(-)
New commits:
commit cdd1e69b2881eec45327e27b297b0cbab44b033e
Author: Frediano Ziglio <fziglio at redhat.com>
Date: Wed Mar 1 17:07:17 2017 +0000
main-dispatcher: Remove watch leak
Watch was added but never removed.
The added basic_event_loop_destroy() addition allows to see that
this leak is gone).
Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
Acked-by: Christophe Fergeau <cfergeau at redhat.com>
diff --git a/server/main-dispatcher.c b/server/main-dispatcher.c
index 09ac1cc..51d6004 100644
--- a/server/main-dispatcher.c
+++ b/server/main-dispatcher.c
@@ -55,6 +55,7 @@ struct MainDispatcherPrivate
{
SpiceCoreInterfaceInternal *core; /* weak */
RedsState *reds; /* weak */
+ SpiceWatch *watch;
};
@@ -105,6 +106,7 @@ main_dispatcher_set_property(GObject *object,
}
static void main_dispatcher_constructed(GObject *object);
+static void main_dispatcher_finalize(GObject *object);
static void
main_dispatcher_class_init(MainDispatcherClass *klass)
@@ -114,6 +116,7 @@ main_dispatcher_class_init(MainDispatcherClass *klass)
g_type_class_add_private(klass, sizeof(MainDispatcherPrivate));
object_class->constructed = main_dispatcher_constructed;
+ object_class->finalize = main_dispatcher_finalize;
object_class->get_property = main_dispatcher_get_property;
object_class->set_property = main_dispatcher_set_property;
@@ -304,10 +307,11 @@ void main_dispatcher_constructed(GObject *object)
G_OBJECT_CLASS(main_dispatcher_parent_class)->constructed(object);
dispatcher_set_opaque(DISPATCHER(self), self);
- self->priv->core->watch_add(self->priv->core,
- dispatcher_get_recv_fd(DISPATCHER(self)),
- SPICE_WATCH_EVENT_READ, dispatcher_handle_read,
- self);
+ self->priv->watch =
+ self->priv->core->watch_add(self->priv->core,
+ dispatcher_get_recv_fd(DISPATCHER(self)),
+ SPICE_WATCH_EVENT_READ, dispatcher_handle_read,
+ self);
dispatcher_register_handler(DISPATCHER(self), MAIN_DISPATCHER_CHANNEL_EVENT,
main_dispatcher_handle_channel_event,
sizeof(MainDispatcherChannelEventMessage), 0 /* no ack */);
@@ -321,3 +325,11 @@ void main_dispatcher_constructed(GObject *object)
main_dispatcher_handle_client_disconnect,
sizeof(MainDispatcherClientDisconnectMessage), 0 /* no ack */);
}
+
+static void main_dispatcher_finalize(GObject *object)
+{
+ MainDispatcher *self = MAIN_DISPATCHER(object);
+
+ self->priv->core->watch_remove(self->priv->core, self->priv->watch);
+ self->priv->watch = NULL;
+}
diff --git a/server/tests/test-leaks.c b/server/tests/test-leaks.c
index cd96bc8..b8521f4 100644
--- a/server/tests/test-leaks.c
+++ b/server/tests/test-leaks.c
@@ -47,6 +47,7 @@ static void leaks(void)
g_assert_cmpint(result, ==, 0);
spice_server_destroy(server);
+ basic_event_loop_destroy();
}
int main(int argc, char *argv[])
More information about the Spice-commits
mailing list