Linux bluetooth development
 help / color / mirror / Atom feed
From: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
To: linux-bluetooth@vger.kernel.org
Subject: [PATCH BlueZ 3/4] android/AVDTP: Add avdtp_shutdown
Date: Thu, 19 Dec 2013 17:15:55 +0200	[thread overview]
Message-ID: <1387466156-14100-3-git-send-email-luiz.dentz@gmail.com> (raw)
In-Reply-To: <1387466156-14100-1-git-send-email-luiz.dentz@gmail.com>

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

avdtp_shutdown can be used to disconnect closing all existing stream
properly.
---
 android/avdtp.c | 19 +++++++++++++++++++
 android/avdtp.h |  2 ++
 2 files changed, 21 insertions(+)

diff --git a/android/avdtp.c b/android/avdtp.c
index b2d77a4..7d3cb18 100644
--- a/android/avdtp.c
+++ b/android/avdtp.c
@@ -2102,6 +2102,25 @@ gboolean avdtp_remove_disconnect_cb(struct avdtp *session, unsigned int id)
 	return FALSE;
 }
 
+void avdtp_shutdown(struct avdtp *session)
+{
+	GSList *l;
+	int sock;
+
+	if (!session->io)
+		return;
+
+	for (l = session->streams; l; l = g_slist_next(l)) {
+		struct avdtp_stream *stream = l->data;
+
+		avdtp_close(session, stream, TRUE);
+	}
+
+	sock = g_io_channel_unix_get_fd(session->io);
+
+	shutdown(sock, SHUT_RDWR);
+}
+
 static void queue_request(struct avdtp *session, struct pending_req *req,
 			gboolean priority)
 {
diff --git a/android/avdtp.h b/android/avdtp.h
index 1619029..d371653 100644
--- a/android/avdtp.h
+++ b/android/avdtp.h
@@ -209,6 +209,8 @@ unsigned int avdtp_add_disconnect_cb(struct avdtp *session,
 						void *user_data);
 gboolean avdtp_remove_disconnect_cb(struct avdtp *session, unsigned int id);
 
+void avdtp_shutdown(struct avdtp *session);
+
 void avdtp_unref(struct avdtp *session);
 struct avdtp *avdtp_ref(struct avdtp *session);
 
-- 
1.8.3.1


  parent reply	other threads:[~2013-12-19 15:15 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-19 15:15 [PATCH BlueZ 1/4] android/AVDTP: Add avdtp_add_disconnect_cb and avdtp_remove_disconnect_cb Luiz Augusto von Dentz
2013-12-19 15:15 ` [PATCH BlueZ 2/4] android/A2DP: Use avdtp_add_disconnect_cb to cleanup on disconnect Luiz Augusto von Dentz
2013-12-19 15:15 ` Luiz Augusto von Dentz [this message]
2013-12-19 15:15 ` [PATCH BlueZ 4/4] android/A2DP: Fix disconnecting after AVDTP session creation Luiz Augusto von Dentz
2013-12-20  7:28 ` [PATCH BlueZ 1/4] android/AVDTP: Add avdtp_add_disconnect_cb and avdtp_remove_disconnect_cb Johan Hedberg

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=1387466156-14100-3-git-send-email-luiz.dentz@gmail.com \
    --to=luiz.dentz@gmail.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