summaryrefslogtreecommitdiffstats
path: root/hcid
diff options
context:
space:
mode:
authorJohan Hedberg <johan.hedberg@nokia.com>2008-01-24 09:16:06 +0000
committerJohan Hedberg <johan.hedberg@nokia.com>2008-01-24 09:16:06 +0000
commit9052739242915a60495d7930ab67debb4ba2ead5 (patch)
treef42cde95aef62dc6adbc8c24a0717e5dc4261c72 /hcid
parent1f9f22f64d5e7c66c6e2d20452f6e5918d0020fb (diff)
Fix external service (un)registration
Diffstat (limited to 'hcid')
-rw-r--r--hcid/dbus-service.c59
1 files changed, 31 insertions, 28 deletions
diff --git a/hcid/dbus-service.c b/hcid/dbus-service.c
index be9dccf5..87881637 100644
--- a/hcid/dbus-service.c
+++ b/hcid/dbus-service.c
@@ -108,6 +108,27 @@ static void service_exit(const char *name, struct service *service)
service->bus_name = NULL;
}
+static void external_service_exit(const char *name, struct service *service)
+{
+ DBusConnection *conn = get_dbus_connection();
+
+ if (!conn)
+ return;
+
+ service_exit(name, service);
+
+ dbus_connection_emit_signal(conn, BASE_PATH, MANAGER_INTERFACE,
+ "ServiceRemoved",
+ DBUS_TYPE_STRING, &service->object_path,
+ DBUS_TYPE_INVALID);
+
+ if (!dbus_connection_destroy_object_path(conn, service->object_path))
+ return;
+
+ services = g_slist_remove(services, service);
+ service_free(service);
+}
+
static DBusHandlerResult get_info(DBusConnection *conn,
DBusMessage *msg, void *data)
{
@@ -760,24 +781,27 @@ static int unregister_service_for_connection(DBusConnection *connection,
if (!conn)
goto cleanup;
- if (service->bus_name)
+ if (service->bus_name) {
+ name_cb_t cb = (name_cb_t) (service->external ?
+ external_service_exit : service_exit);
name_listener_remove(connection, service->bus_name,
- (name_cb_t) service_exit, service);
+ cb, service);
+ }
dbus_connection_emit_signal(conn, service->object_path,
SERVICE_INTERFACE,
"Stopped", DBUS_TYPE_INVALID);
- if (!dbus_connection_destroy_object_path(conn, service->object_path)) {
- error("D-Bus failed to unregister %s object", service->object_path);
- return -1;
- }
-
dbus_connection_emit_signal(conn, BASE_PATH, MANAGER_INTERFACE,
"ServiceRemoved",
DBUS_TYPE_STRING, &service->object_path,
DBUS_TYPE_INVALID);
+ if (!dbus_connection_destroy_object_path(conn, service->object_path)) {
+ error("D-Bus failed to unregister %s object", service->object_path);
+ return -1;
+ }
+
cleanup:
if (service->pid) {
if (service->startup_timer) {
@@ -1038,27 +1062,6 @@ static struct service *create_external_service(const char *ident,
return service;
}
-static void external_service_exit(const char *name, struct service *service)
-{
- DBusConnection *conn = get_dbus_connection();
-
- service_exit(name, service);
-
- if (!conn)
- return;
-
- if (!dbus_connection_destroy_object_path(conn, service->object_path))
- return;
-
- dbus_connection_emit_signal(conn, BASE_PATH, MANAGER_INTERFACE,
- "ServiceRemoved",
- DBUS_TYPE_STRING, &service->object_path,
- DBUS_TYPE_INVALID);
-
- services = g_slist_remove(services, service);
- service_free(service);
-}
-
int service_register(DBusConnection *conn, const char *bus_name, const char *ident,
const char *name, const char *description)
{