diff options
author | Johan Hedberg <johan.hedberg@nokia.com> | 2007-01-15 21:53:06 +0000 |
---|---|---|
committer | Johan Hedberg <johan.hedberg@nokia.com> | 2007-01-15 21:53:06 +0000 |
commit | 6cfaa54f617b72bb9c34253a5bb0de35ebfb905a (patch) | |
tree | 3ec7015471327b7914f7f8e8ed54e66c652384c2 /hcid/dbus-service.c | |
parent | f1b0df0a0b19e2e5229540bea547bd83b72af327 (diff) |
Properly cleanup active services when exiting
Diffstat (limited to 'hcid/dbus-service.c')
-rw-r--r-- | hcid/dbus-service.c | 29 |
1 files changed, 25 insertions, 4 deletions
diff --git a/hcid/dbus-service.c b/hcid/dbus-service.c index 67b9ccfc..a0c51ecb 100644 --- a/hcid/dbus-service.c +++ b/hcid/dbus-service.c @@ -755,6 +755,30 @@ int unregister_service(const char *sender, const char *path) return 0; } +static void release_service(struct service *service) +{ + if (service->records) + unregister_service_records(service->records); + + if (service->bus_name) + name_listener_remove(get_dbus_connection(), service->bus_name, + (name_cb_t) service_exit, service); + + if (service->watch_id) + g_source_remove(service->watch_id); + + if (service->pid) + kill(service->pid, SIGKILL); + + if (service->startup_timer) + g_timeout_remove(service->startup_timer); + + if (service->shutdown_timer) + g_timeout_remove(service->shutdown_timer); + + service_free(service); +} + void release_services(DBusConnection *conn) { GSList *l = services; @@ -772,10 +796,7 @@ void release_services(DBusConnection *conn) if (!service) continue; - if (service->records) - unregister_service_records(service->records); - - service_free(service); + release_service(service); } dbus_connection_unregister_object_path(conn, path); |