diff options
author | Marcel Holtmann <marcel@holtmann.org> | 2008-06-08 13:49:39 +0000 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2008-06-08 13:49:39 +0000 |
commit | c1f7605e7afb22c24f4b241afd36526e6181e7ef (patch) | |
tree | 6e3bb5a499ae838a046abec381aeb1f16aba6df4 | |
parent | 1008177538c7f2fac766d6144b7f653719c56328 (diff) |
Fix missing disconnect watch id handling
-rw-r--r-- | hcid/adapter.c | 8 | ||||
-rw-r--r-- | hcid/dbus-database.c | 21 |
2 files changed, 17 insertions, 12 deletions
diff --git a/hcid/adapter.c b/hcid/adapter.c index 3948908a..6b618599 100644 --- a/hcid/adapter.c +++ b/hcid/adapter.c @@ -4015,7 +4015,7 @@ static DBusMessage *register_agent(DBusConnection *conn, if (!dbus_message_get_args(msg, NULL, DBUS_TYPE_OBJECT_PATH, &path, DBUS_TYPE_STRING, &capability, DBUS_TYPE_INVALID)) - return invalid_args(msg); + return NULL; if (adapter->agent) return g_dbus_create_error(msg, @@ -4051,7 +4051,7 @@ static DBusMessage *unregister_agent(DBusConnection *conn, if (!dbus_message_get_args(msg, NULL, DBUS_TYPE_OBJECT_PATH, &path, DBUS_TYPE_INVALID)) - return invalid_args(msg); + return NULL; name = dbus_message_get_sender(msg); @@ -4078,7 +4078,7 @@ static DBusMessage *add_service_record(DBusConnection *conn, if (dbus_message_get_args(msg, NULL, DBUS_TYPE_STRING, &record, DBUS_TYPE_INVALID) == FALSE) - return invalid_args(msg); + return NULL; sender = dbus_message_get_sender(msg); str2ba(adapter->address, &src); @@ -4115,7 +4115,7 @@ static DBusMessage *remove_service_record(DBusConnection *conn, if (dbus_message_get_args(msg, NULL, DBUS_TYPE_UINT32, &handle, DBUS_TYPE_INVALID) == FALSE) - return invalid_args(msg); + return NULL; sender = dbus_message_get_sender(msg); diff --git a/hcid/dbus-database.c b/hcid/dbus-database.c index e9df79b0..c6a689d2 100644 --- a/hcid/dbus-database.c +++ b/hcid/dbus-database.c @@ -75,6 +75,8 @@ static void exit_callback(void *user_data) { struct record_data *user_record = user_data; + debug("remove record"); + records = g_slist_remove(records, user_record); remove_record_from_server(user_record->handle); @@ -150,6 +152,8 @@ static DBusMessage *add_service_record(DBusConnection *conn, user_record, NULL); + debug("listener_id %d", user_record->listener_id); + return g_dbus_create_reply(msg, DBUS_TYPE_UINT32, &user_record->handle, DBUS_TYPE_INVALID); } @@ -180,8 +184,10 @@ int add_xml_record(DBusConnection *conn, const char *sender, bdaddr_t *src, records = g_slist_append(records, user_record); - g_dbus_add_disconnect_watch(conn, sender, exit_callback, user_record, - NULL); + user_record->listener_id = g_dbus_add_disconnect_watch(conn, sender, + exit_callback, user_record, NULL); + + debug("listener_id %d", user_record->listener_id); *handle = user_record->handle; @@ -320,18 +326,17 @@ int remove_record(DBusConnection *conn, const char *sender, { struct record_data *user_record; + debug("remove record 0x%x", handle); + user_record = find_record(handle, sender); if (!user_record) return -1; - g_dbus_remove_watch(conn, user_record->listener_id); + debug("listner_id %d", user_record->listener_id); - records = g_slist_remove(records, user_record); - - remove_record_from_server(handle); + g_dbus_remove_watch(conn, user_record->listener_id); - g_free(user_record->sender); - g_free(user_record); + exit_callback(user_record); return 0; } |