while (gadapter->sdp_handles != NULL) {
uint32_t handle = GPOINTER_TO_UINT(gadapter->sdp_handles->data);
- attrib_free_sdp(handle);
+ attrib_free_sdp(gadapter->adapter, handle);
gadapter->sdp_handles = g_slist_remove(gadapter->sdp_handles,
gadapter->sdp_handles->data);
}
return;
server->sources = g_slist_remove(server->sources, sep);
if (server->sources == NULL && server->source_record_id) {
- remove_record_from_server(server->source_record_id);
+ adapter_service_remove(server->adapter,
+ server->source_record_id);
server->source_record_id = 0;
}
} else {
return;
server->sinks = g_slist_remove(server->sinks, sep);
if (server->sinks == NULL && server->sink_record_id) {
- remove_record_from_server(server->sink_record_id);
+ adapter_service_remove(server->adapter,
+ server->sink_record_id);
server->sink_record_id = 0;
}
}
(GDestroyNotify) a2dp_unregister_sep);
if (server->source_record_id) {
- remove_record_from_server(server->source_record_id);
+ adapter_service_remove(server->adapter,
+ server->source_record_id);
server->source_record_id = 0;
}
g_slist_free_full(server->sinks, (GDestroyNotify) a2dp_unregister_sep);
if (server->sink_record_id) {
- remove_record_from_server(server->sink_record_id);
+ adapter_service_remove(server->adapter, server->sink_record_id);
server->sink_record_id = 0;
}
return;
if (server->tg_record_id != 0) {
- remove_record_from_server(server->tg_record_id);
+ adapter_service_remove(adapter, server->tg_record_id);
server->tg_record_id = 0;
}
return;
if (server->ct_record_id != 0) {
- remove_record_from_server(server->ct_record_id);
+ adapter_service_remove(adapter, server->ct_record_id);
server->ct_record_id = 0;
}
hdp_adapter = l->data;
adapters = g_slist_remove(adapters, hdp_adapter);
if (hdp_adapter->sdp_handler > 0)
- remove_record_from_server(hdp_adapter->sdp_handler);
+ adapter_service_remove(adapter, hdp_adapter->sdp_handler);
release_adapter_instance(hdp_adapter);
btd_adapter_unref(hdp_adapter->btd_adapter);
g_free(hdp_adapter);
sdp_record_t *sdp_record;
if (adapter->sdp_handler > 0)
- remove_record_from_server(adapter->sdp_handler);
+ adapter_service_remove(adapter->btd_adapter,
+ adapter->sdp_handler);
if (app_list == NULL) {
adapter->sdp_handler = 0;
ns->watch_id = 0;
if (ns->record_id) {
- remove_record_from_server(ns->record_id);
+ adapter_service_remove(ns->na->adapter, ns->record_id);
ns->record_id = 0;
}
server_remove_sessions(ns);
if (ns->record_id)
- remove_record_from_server(ns->record_id);
+ adapter_service_remove(ns->na->adapter, ns->record_id);
g_dbus_remove_watch(btd_get_dbus_connection(), ns->watch_id);
g_free(ns->name);
sap_server_remove_conn(server);
- remove_record_from_server(server->record_id);
+ adapter_service_remove(server->adapter, server->record_id);
if (server->listen_io) {
g_io_channel_shutdown(server->listen_io, TRUE, NULL);
return 0;
}
-void adapter_service_remove(struct btd_adapter *adapter, void *r)
+void adapter_service_remove(struct btd_adapter *adapter, uint32_t handle)
{
- sdp_record_t *rec = r;
+ sdp_record_t *rec = sdp_record_find(handle);
DBG("%s", adapter->path);
+ if (!rec)
+ return;
+
adapter->services = sdp_list_remove(adapter->services, rec);
- if (sdp_list_find(adapter->services, &rec->svclass, uuid_cmp))
- return;
+ if (sdp_list_find(adapter->services, &rec->svclass, uuid_cmp) == NULL)
+ remove_uuid(adapter, &rec->svclass);
- remove_uuid(adapter, &rec->svclass);
+ remove_record_from_server(rec->handle);
}
static struct btd_device *adapter_create_device(struct btd_adapter *adapter,
int adapter_set_name(struct btd_adapter *adapter, const char *name);
int adapter_service_add(struct btd_adapter *adapter, sdp_record_t *rec);
-void adapter_service_remove(struct btd_adapter *adapter, void *rec);
+void adapter_service_remove(struct btd_adapter *adapter, uint32_t handle);
struct agent *adapter_get_agent(struct btd_adapter *adapter);
g_slist_free_full(server->clients, (GDestroyNotify) channel_free);
if (server->gatt_sdp_handle > 0)
- remove_record_from_server(server->gatt_sdp_handle);
+ adapter_service_remove(server->adapter,
+ server->gatt_sdp_handle);
if (server->gap_sdp_handle > 0)
- remove_record_from_server(server->gap_sdp_handle);
+ adapter_service_remove(server->adapter, server->gap_sdp_handle);
if (server->adapter != NULL)
btd_adapter_unref(server->adapter);
return attrib_create_sdp_new(l->data, handle, name);
}
-void attrib_free_sdp(uint32_t sdp_handle)
+void attrib_free_sdp(struct btd_adapter *adapter, uint32_t sdp_handle)
{
- remove_record_from_server(sdp_handle);
+ adapter_service_remove(adapter, sdp_handle);
}
static uint16_t find_uuid16_avail(struct btd_adapter *adapter, uint16_t nitems)
const uint8_t *value, size_t len);
uint32_t attrib_create_sdp(struct btd_adapter *adapter, uint16_t handle,
const char *name);
-void attrib_free_sdp(uint32_t sdp_handle);
+void attrib_free_sdp(struct btd_adapter *adapter, uint32_t sdp_handle);
guint attrib_channel_attach(GAttrib *attrib);
gboolean attrib_channel_detach(GAttrib *attrib, guint id);
ext->records = g_slist_remove(ext->records, r);
- remove_record_from_server(r->handle);
+ adapter_service_remove(adapter, r->handle);
btd_adapter_unref(r->adapter);
g_free(r);
}
#include "sdpd.h"
#include "log.h"
-#include "adapter.h"
static sdp_list_t *service_db;
static sdp_list_t *access_db;
a = p->data;
- if (bacmp(&a->device, BDADDR_ANY) != 0) {
- struct btd_adapter *adapter = adapter_find(&a->device);
- if (adapter)
- adapter_service_remove(adapter, r);
- } else
- adapter_foreach(adapter_service_remove, r);
-
access_db = sdp_list_remove(access_db, a);
access_free(a);