summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathon Jongsma <jjongsma@redhat.com>2015-06-09 10:53:55 -0500
committerFrediano Ziglio <fziglio@redhat.com>2015-10-02 10:15:56 +0100
commitf360eb1d5fdcdd0b4a9c44645dbdc4d80869b9d4 (patch)
treed426804fdee43414d055b09996e54c6389079042
parente38e6c0bc14986c42413da5e34bf6b49f592f6fd (diff)
Manage lifetime of spicevmc channel
Store the channel in the char device object, and unref it in dispose. Previously, we were just creating a channel and allowing it to leak. There may be better long-term solutions, but this works for now.
-rw-r--r--server/spicevmc.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/server/spicevmc.c b/server/spicevmc.c
index ab58a4ee..86cbc8d1 100644
--- a/server/spicevmc.c
+++ b/server/spicevmc.c
@@ -76,6 +76,7 @@ struct _RedCharDeviceSpiceVmcClass
struct _RedCharDeviceSpiceVmcPrivate {
SpiceVmcPipeItem *pipe_item;
+ RedChannel *channel;
};
static GType red_char_device_spicevmc_get_type(void) G_GNUC_CONST;
@@ -670,9 +671,13 @@ SpiceCharDeviceState *spicevmc_device_connect(RedsState *reds,
SpiceCharDeviceInstance *sin,
uint8_t channel_type)
{
+ RedCharDeviceSpiceVmc *dev_state;
SpiceVmcState *state = spice_vmc_state_new(reds, channel_type, sin);
- return state->priv->chardev_st;
+ dev_state = RED_CHAR_DEVICE_SPICEVMC(state->priv->chardev_st);
+ dev_state->priv->channel = RED_CHANNEL(state);
+
+ return RED_CHAR_DEVICE(dev_state);
}
/* Must be called from RedClient handling thread. */
@@ -712,6 +717,14 @@ SPICE_GNUC_VISIBLE void spice_server_port_event(SpiceCharDeviceInstance *sin, ui
}
static void
+red_char_device_spicevmc_dispose(GObject *object)
+{
+ RedCharDeviceSpiceVmc *self = RED_CHAR_DEVICE_SPICEVMC(object);
+
+ g_clear_object(&self->priv->channel);
+}
+
+static void
red_char_device_spicevmc_finalize(GObject *object)
{
RedCharDeviceSpiceVmc *self = RED_CHAR_DEVICE_SPICEVMC(object);
@@ -727,6 +740,7 @@ red_char_device_spicevmc_class_init(RedCharDeviceSpiceVmcClass *klass)
g_type_class_add_private(klass, sizeof (RedCharDeviceSpiceVmcPrivate));
+ object_class->dispose = red_char_device_spicevmc_dispose;
object_class->finalize = red_char_device_spicevmc_finalize;
char_dev_class->read_one_msg_from_device = spicevmc_chardev_read_msg_from_dev;