Diff between d010757dd10079f4172a5082d32dd43f454a85c7 and 76ba5e2e1834cc29fa42c42edcf8a2054d7d73a2

Changed Files

File Additions Deletions Status
profiles/network/connection.c +7 -5 modified

Full Patch

diff --git a/profiles/network/connection.c b/profiles/network/connection.c
index 16ee318..8fbde14 100644
--- a/profiles/network/connection.c
+++ b/profiles/network/connection.c
@@ -67,6 +67,7 @@ struct network_peer {
 };
 
 struct network_conn {
+	struct btd_service *service;
 	char		dev[16];	/* Interface name */
 	uint16_t	id;		/* Role: Service Class Identifier */
 	conn_state	state;
@@ -606,6 +607,7 @@ static void connection_free(void *data)
 	if (nc->connect)
 		dbus_message_unref(nc->connect);
 
+	btd_service_unref(nc->service);
 	g_free(nc);
 }
 
@@ -649,15 +651,12 @@ static const GDBusPropertyTable connection_properties[] = {
 void connection_unregister(struct btd_service *service)
 {
 	struct btd_device *device = btd_service_get_device(service);
-	struct network_peer *peer;
+	struct network_conn *conn = btd_service_get_user_data(service);
+	struct network_peer *peer = conn->peer;
 	uint16_t id = get_service_id(service);
 
 	DBG("%s id %u", device_get_path(device), id);
 
-	peer = find_peer(peers, device);
-	if (!peer)
-		return;
-
 	g_slist_free_full(peer->connections, connection_free);
 	peer->connections = NULL;
 
@@ -721,9 +720,12 @@ int connection_register(struct btd_service *service)
 	nc->id = id;
 	memset(nc->dev, 0, sizeof(nc->dev));
 	strcpy(nc->dev, "bnep%d");
+	nc->service = btd_service_ref(service);
 	nc->state = DISCONNECTED;
 	nc->peer = peer;
 
+	btd_service_set_user_data(service, nc);
+
 	DBG("id %u registered", id);
 
 	peer->connections = g_slist_append(peer->connections, nc);