Linux bluetooth development
 help / color / mirror / Atom feed
From: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
To: linux-bluetooth@vger.kernel.org
Cc: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
Subject: [PATCH 3/5] network: Release session's interface from bridge when unregistering
Date: Tue, 21 Aug 2012 13:45:53 +0300	[thread overview]
Message-ID: <1345545955-13144-4-git-send-email-tomasz.bursztyka@linux.intel.com> (raw)
In-Reply-To: <1345545955-13144-1-git-send-email-tomasz.bursztyka@linux.intel.com>

---
 profiles/network/server.c |   24 +++++++++++++++++++++---
 1 files changed, 21 insertions(+), 3 deletions(-)

diff --git a/profiles/network/server.c b/profiles/network/server.c
index 1703f38..5d64ee2 100644
--- a/profiles/network/server.c
+++ b/profiles/network/server.c
@@ -586,6 +586,25 @@ static uint32_t register_server_record(struct network_server *ns)
 	return record->handle;
 }
 
+static void server_remove_sessions(struct network_server *ns)
+{
+	GSList *list;
+
+	for (list = ns->sessions; list; list = list->next) {
+		struct network_session *session = list->data;
+
+		if (*session->dev == '\0')
+			continue;
+
+		bnep_del_from_bridge(session->dev, ns->bridge);
+		bnep_if_down(session->dev);
+	}
+
+	g_slist_free_full(ns->sessions, session_free);
+
+	ns->sessions = NULL;
+}
+
 static void server_disconnect(DBusConnection *conn, void *user_data)
 {
 	struct network_server *ns = user_data;
@@ -678,7 +697,8 @@ static void server_free(struct network_server *ns)
 	if (!ns)
 		return;
 
-	/* FIXME: Missing release/free all bnepX interfaces */
+	server_remove_sessions(ns);
+
 	if (ns->record_id)
 		remove_record_from_server(ns->record_id);
 
@@ -686,8 +706,6 @@ static void server_free(struct network_server *ns)
 	g_free(ns->name);
 	g_free(ns->bridge);
 
-	g_slist_free_full(ns->sessions, session_free);
-
 	g_free(ns);
 }
 
-- 
1.7.8.6


  parent reply	other threads:[~2012-08-21 10:45 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-08-21 10:45 [PATCH 0/5] PAN server fixes Tomasz Bursztyka
2012-08-21 10:45 ` [PATCH 1/5] network: Keep track of session's interface name in server Tomasz Bursztyka
2012-08-21 10:45 ` [PATCH 2/5] network: Add helper function to remove an interface from a bridge Tomasz Bursztyka
2012-08-21 10:45 ` Tomasz Bursztyka [this message]
2012-08-21 10:45 ` [PATCH 4/5] network: Kill underlying session's connection before freeing it Tomasz Bursztyka
2012-08-21 10:45 ` [PATCH 5/5] network: Remove sessions from server on DBus call Unregister Tomasz Bursztyka
2012-08-24  7:54 ` [PATCH 0/5] PAN server fixes Luiz Augusto von Dentz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1345545955-13144-4-git-send-email-tomasz.bursztyka@linux.intel.com \
    --to=tomasz.bursztyka@linux.intel.com \
    --cc=linux-bluetooth@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox