summaryrefslogtreecommitdiffstats
path: root/hcid/dbus-service.c
diff options
context:
space:
mode:
authorJohan Hedberg <johan.hedberg@nokia.com>2007-01-15 20:25:27 +0000
committerJohan Hedberg <johan.hedberg@nokia.com>2007-01-15 20:25:27 +0000
commit5886e18ef914d01baa871aebff7976938543fb66 (patch)
tree7efa7f8a42a8f93cde0b43c79a44903769486a36 /hcid/dbus-service.c
parent8c73bcb914155e93957c9c2d8a8d029ef258a51f (diff)
Fix service name owner exit situation
Diffstat (limited to 'hcid/dbus-service.c')
-rw-r--r--hcid/dbus-service.c49
1 files changed, 13 insertions, 36 deletions
diff --git a/hcid/dbus-service.c b/hcid/dbus-service.c
index 8ad499a5..228587e2 100644
--- a/hcid/dbus-service.c
+++ b/hcid/dbus-service.c
@@ -193,45 +193,22 @@ static int unregister_service_records(GSList *lrecords)
return 0;
}
-static void service_exit(const char *name, void *data)
+static void service_exit(const char *name, struct service *service)
{
- DBusConnection *conn = data;
- DBusMessage *message;
- GSList *l, *lremove = NULL;
- struct service *service;
- const char *path;
+ DBusConnection *conn = get_dbus_connection();
+ DBusMessage *signal;
- debug("Service Agent exited:%s", name);
-
- /* Remove all service services assigned to this owner */
- for (l = services; l; l = l->next) {
- path = l->data;
-
- if (!dbus_connection_get_object_path_data(conn, path, (void *) &service))
- continue;
-
- if (!service || strcmp(name, service->bus_name))
- continue;
+ debug("Service owner exited: %s", name);
- if (service->records)
- unregister_service_records(service->records);
-
- dbus_connection_unregister_object_path(conn, path);
-
- message = dbus_message_new_signal(service->object_path,
- SERVICE_INTERFACE, "Stopped");
- dbus_message_append_args(message, DBUS_TYPE_STRING, &path,
- DBUS_TYPE_INVALID);
- send_message_and_unref(conn, message);
+ if (service->records)
+ unregister_service_records(service->records);
- service_free(service);
-
- lremove = g_slist_append(lremove, l->data);
- services = g_slist_remove(services, l->data);
- }
+ signal = dbus_message_new_signal(service->object_path,
+ SERVICE_INTERFACE, "Stopped");
+ send_message_and_unref(conn, signal);
- g_slist_foreach(lremove, (GFunc) free, NULL);
- g_slist_free(lremove);
+ free(service->bus_name);
+ service->bus_name = NULL;
}
static void forward_reply(DBusPendingCall *call, void *udata)
@@ -382,7 +359,7 @@ static DBusHandlerResult service_filter(DBusConnection *conn,
g_timeout_remove(service->startup_timer);
service->startup_timer = 0;
- name_listener_add(conn, new, service_exit, conn);
+ name_listener_add(conn, new, (name_cb_t) service_exit, service);
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
}
@@ -705,7 +682,7 @@ int unregister_service(const char *sender, const char *path)
if (!dbus_connection_unregister_object_path(conn, path))
return -ENOMEM;
- name_listener_remove(conn, sender, (name_cb_t) service_exit, conn);
+ name_listener_remove(conn, sender, (name_cb_t) service_exit, service);
l = g_slist_find_custom(services, path, (GCompareFunc) strcmp);
if (l) {