From: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
To: linux-bluetooth@vger.kernel.org
Cc: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
Subject: [PATCH_v3 6/6] anrdroid/client/health: Cache fd and close on channel disconnection
Date: Sun, 22 Jun 2014 14:59:01 +0300 [thread overview]
Message-ID: <1403438341-14321-7-git-send-email-ravikumar.veeramally@linux.intel.com> (raw)
In-Reply-To: <1403438341-14321-1-git-send-email-ravikumar.veeramally@linux.intel.com>
Cache fd and close them on channel disconnect or destroy notification.
When running PTS tests it is expecting to close all data channels before
exiting test case.
---
android/client/if-hl.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/android/client/if-hl.c b/android/client/if-hl.c
index 557a205..5940526 100644
--- a/android/client/if-hl.c
+++ b/android/client/if-hl.c
@@ -17,6 +17,7 @@
#include<stdio.h>
#include<ctype.h>
+#include<unistd.h>
#include<hardware/bluetooth.h>
#include<hardware/bt_hl.h>
@@ -52,6 +53,7 @@ SINTMAP(bthl_channel_state_t, -1, "(unknown)")
ENDMAP
const bthl_interface_t *if_hl = NULL;
+static int fd_list[256] = {-1};
static void app_reg_state_cb(int app_id, bthl_app_reg_state_t state)
{
@@ -69,6 +71,13 @@ static void channel_state_cb(int app_id, bt_bdaddr_t *bd_addr,
"channel_id=%d channel_state=%s fd=%d\n", __func__,
app_id, bt_bdaddr_t2str(bd_addr, addr), mdep_cfg_index,
channel_id, bthl_channel_state_t2str(state), fd);
+
+ if (state == BTHL_CONN_STATE_CONNECTED)
+ fd_list[channel_id] = fd;
+
+ if (state == BTHL_CONN_STATE_DISCONNECTED ||
+ state == BTHL_CONN_STATE_DESTROYED)
+ close(fd_list[channel_id]);
}
static bthl_callbacks_t hl_cbacks = {
--
1.9.1
next prev parent reply other threads:[~2014-06-22 11:59 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-06-22 11:58 [PATCH_v3 0/6] Initial implementation for MCAP data channel Ravi kumar Veeramally
2014-06-22 11:58 ` [PATCH_v3 1/6] android/health: Check if device and channel already exists or not Ravi kumar Veeramally
2014-06-22 11:58 ` [PATCH_v3 2/6] android/health: Cache remote mdep id on channel connect request Ravi kumar Veeramally
2014-06-22 11:58 ` [PATCH_v3 3/6] android/health: Notify channel status on channel destroy call Ravi kumar Veeramally
2014-06-22 11:58 ` [PATCH_v3 4/6] android/health: Create and connect MDL Ravi kumar Veeramally
2014-06-22 11:59 ` [PATCH_v3 5/6] android/health: Implement mcap_mdl_deleted_cb Ravi kumar Veeramally
2014-06-22 11:59 ` Ravi kumar Veeramally [this message]
2014-06-23 9:15 ` [PATCH_v3 0/6] Initial implementation for MCAP data channel Szymon Janc
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=1403438341-14321-7-git-send-email-ravikumar.veeramally@linux.intel.com \
--to=ravikumar.veeramally@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