From 9f9383e6ffb830bb9b0c95692273820eb785bdbc Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Wed, 9 Mar 2016 13:25:44 +1000 Subject: [PATCH 1/3] profile: free the buttons/resolutions on profile cleanup Signed-off-by: Peter Hutterer --- src/ratbagd-profile.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/ratbagd-profile.c b/src/ratbagd-profile.c index 77de4746..880fda81 100644 --- a/src/ratbagd-profile.c +++ b/src/ratbagd-profile.c @@ -362,9 +362,24 @@ int ratbagd_profile_new(struct ratbagd_profile **out, struct ratbagd_profile *ratbagd_profile_free(struct ratbagd_profile *profile) { + unsigned int i; + if (!profile) return NULL; + profile->resolution_vtable_slot = sd_bus_slot_unref(profile->resolution_vtable_slot); + profile->resolution_enum_slot = sd_bus_slot_unref(profile->resolution_enum_slot); + profile->button_vtable_slot = sd_bus_slot_unref(profile->button_vtable_slot); + profile->button_enum_slot = sd_bus_slot_unref(profile->button_enum_slot); + + for (i = 0; i< profile->n_buttons; ++i) + ratbagd_button_free(profile->buttons[i]); + for (i = 0; i< profile->n_resolutions; ++i) + ratbagd_resolution_free(profile->resolutions[i]); + + mfree(profile->buttons); + mfree(profile->resolutions); + profile->path = mfree(profile->path); /* we cannot assume the profile is gone, so set NULL explicitly */ From 819c70fa9ad12ff895dd8bb4a10cfc1df9e7c140 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Wed, 9 Mar 2016 13:41:04 +1000 Subject: [PATCH 2/3] systemd: restart on abort Now that we clean up properly, the most common crash should be fixed. Restart on abort by default so ideally all we need to do is restart piper or whatever consumes the API. Signed-off-by: Peter Hutterer --- ratbagd.service.in | 1 + 1 file changed, 1 insertion(+) diff --git a/ratbagd.service.in b/ratbagd.service.in index 053bc77f..db07f0aa 100644 --- a/ratbagd.service.in +++ b/ratbagd.service.in @@ -5,6 +5,7 @@ Description=Daemon to introspect and modify configuable mice Type=dbus BusName=org.freedesktop.ratbag1 ExecStart=__BIN_PREFIX__/ratbagd +Restart=on-abort [Install] WantedBy=multi-user.target From a066203b4a9eb6c83ca07a34ed46f30d18456fbc Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Wed, 9 Mar 2016 14:08:20 +1000 Subject: [PATCH 3/3] systemd: fix typo in service file Signed-off-by: Peter Hutterer --- ratbagd.service.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ratbagd.service.in b/ratbagd.service.in index db07f0aa..ef9b7342 100644 --- a/ratbagd.service.in +++ b/ratbagd.service.in @@ -1,5 +1,5 @@ [Unit] -Description=Daemon to introspect and modify configuable mice +Description=Daemon to introspect and modify configurable mice [Service] Type=dbus