summaryrefslogtreecommitdiff
path: root/src/up-daemon.c
diff options
context:
space:
mode:
authorPeter Wu <peter@lekensteyn.nl>2014-11-20 15:55:37 +0100
committerPeter Wu <peter@lekensteyn.nl>2014-11-26 11:40:49 +0100
commit059e3e09393c3aae5b31ec8edec9575460e6aaf5 (patch)
tree343aa8ec2c9dee4534d44f0868b5606945f8eb27 /src/up-daemon.c
parent8b4778da082e0892441417484b7c2025a5e2e498 (diff)
downloadupower-059e3e09393c3aae5b31ec8edec9575460e6aaf5.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/up-daemon.c')
-rw-r--r--src/up-daemon.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/up-daemon.c b/src/up-daemon.c
index c795c93..f857c00 100644
--- a/src/up-daemon.c
+++ b/src/up-daemon.c
@@ -547,6 +547,24 @@ out:
}
/**
+ * up_daemon_shutdown:
+ *
+ * Stop the daemon, release all devices and resources.
+ **/
+void
+up_daemon_shutdown (UpDaemon *daemon)
+{
+ /* stop accepting new devices and clear backend state */
+ up_backend_unplug (daemon->priv->backend);
+
+ /* forget about discovered devices and release UpDaemon reference */
+ up_device_list_clear (daemon->priv->power_devices, TRUE);
+
+ /* release UpDaemon reference */
+ up_device_unplug (daemon->priv->display_device);
+}
+
+/**
* up_daemon_get_device_list:
**/
UpDeviceList *