summaryrefslogtreecommitdiff
path: root/src/linux
diff options
context:
space:
mode:
authorPeter Wu <peter@lekensteyn.nl>2014-11-20 15:55:37 +0100
committerRichard Hughes <richard@hughsie.com>2014-11-26 11:56:16 +0000
commit90994b0d81ca8e44e6a150c53d2c713fad39c29c (patch)
tree343aa8ec2c9dee4534d44f0868b5606945f8eb27 /src/linux
parenta91d03a3a9310b5d00e65a249aab2241906733bc (diff)
downloadupower-90994b0d81ca8e44e6a150c53d2c713fad39c29c.tar.gz
daemon: release resources at shutdown
This makes it easier to find real memory leaks with valgrind. After calling the up_backend_unplug functions, you cannot restart it with up_backend_coldplug since the lists are cleared. Tested with Linux only (not on *BSD; dummy compiles). https://bugs.freedesktop.org/show_bug.cgi?id=82659
Diffstat (limited to 'src/linux')
-rw-r--r--src/linux/up-backend.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/linux/up-backend.c b/src/linux/up-backend.c
index f45ce29..b7a129d 100644
--- a/src/linux/up-backend.c
+++ b/src/linux/up-backend.c
@@ -340,6 +340,33 @@ up_backend_coldplug (UpBackend *backend, UpDaemon *daemon)
return TRUE;
}
+/**
+ * up_backend_unplug:
+ * @backend: The %UpBackend class instance
+ *
+ * Forget about all learned devices, effectively undoing up_backend_coldplug.
+ * Resources are released without emitting signals.
+ */
+void
+up_backend_unplug (UpBackend *backend)
+{
+ if (backend->priv->gudev_client != NULL) {
+ g_object_unref (backend->priv->gudev_client);
+ backend->priv->gudev_client = NULL;
+ }
+ if (backend->priv->device_list != NULL) {
+ g_object_unref (backend->priv->device_list);
+ backend->priv->device_list = NULL;
+ }
+ /* set in init, clear the list to remove reference to UpDaemon */
+ if (backend->priv->managed_devices != NULL)
+ up_device_list_clear (backend->priv->managed_devices, FALSE);
+ if (backend->priv->daemon != NULL) {
+ g_object_unref (backend->priv->daemon);
+ backend->priv->daemon = NULL;
+ }
+}
+
static gboolean
check_action_result (GVariant *result)
{