diff options
author | zzy <zhenye@broadcom.com> | 2012-04-04 18:22:29 -0700 |
---|---|---|
committer | Matthew Xie <mattx@google.com> | 2012-07-14 11:19:14 -0700 |
commit | e8070c41e25c6f0d368d7a53c0641524ea4630d2 (patch) | |
tree | b5c08fa24ac84f7d7fac0478bb421aab0b9d151d /btif | |
parent | b888218fb9061d8ddf41013dba6d0956b3322fd6 (diff) | |
download | external_bluetooth_bluedroid-e8070c41e25c6f0d368d7a53c0641524ea4630d2.zip external_bluetooth_bluedroid-e8070c41e25c6f0d368d7a53c0641524ea4630d2.tar.gz external_bluetooth_bluedroid-e8070c41e25c6f0d368d7a53c0641524ea4630d2.tar.bz2 |
added code to cleanup sockets and workaround when bluetooth process does not exit when bt off
Diffstat (limited to 'btif')
-rw-r--r-- | btif/include/btif_sock_rfc.h | 3 | ||||
-rw-r--r-- | btif/src/btif_core.c | 2 | ||||
-rw-r--r-- | btif/src/btif_sock.c | 4 | ||||
-rw-r--r-- | btif/src/btif_sock_rfc.c | 13 |
4 files changed, 20 insertions, 2 deletions
diff --git a/btif/include/btif_sock_rfc.h b/btif/include/btif_sock_rfc.h index 5bf13ed..2415513 100644 --- a/btif/include/btif_sock_rfc.h +++ b/btif/include/btif_sock_rfc.h @@ -56,7 +56,8 @@ #ifndef btif_sock_rfc_h_ #define btif_sock_rfc_h_ -bt_status_t btsock_rfc_init(); +bt_status_t btsock_rfc_init(int handle); +bt_status_t btsock_rfc_cleanup(); bt_status_t btsock_rfc_listen(const char* name, const uint8_t* uuid, int channel, int* sock_fd, int flags); bt_status_t btsock_rfc_connect(const bt_bdaddr_t *bd_addr, const uint8_t* uuid, int channel, int* sock_fd, int flags); void btsock_rfc_signaled(int fd, int flags, uint32_t user_id); diff --git a/btif/src/btif_core.c b/btif/src/btif_core.c index 66f0a7e..560394f 100644 --- a/btif/src/btif_core.c +++ b/btif/src/btif_core.c @@ -460,6 +460,8 @@ bt_status_t btif_disable_bluetooth(void) BTIF_TRACE_DEBUG1("%s", __FUNCTION__); + //cleanup rfcomm & l2cap api + btif_sock_cleanup(); status = BTA_DisableBluetooth(); if (status != BTA_SUCCESS) diff --git a/btif/src/btif_sock.c b/btif/src/btif_sock.c index 859c329..9e57c4b 100644 --- a/btif/src/btif_sock.c +++ b/btif/src/btif_sock.c @@ -103,7 +103,8 @@ bt_status_t btif_sock_init() static volatile int binit; if(!binit) { - binit = 1; + //fix me, the process doesn't exit right now. don't set the init flag for now + //binit = 1; debug("btsock initializing..."); btsock_thread_init(); int handle = btsock_thread_create(btsock_signaled); @@ -119,6 +120,7 @@ bt_status_t btif_sock_init() void btif_sock_cleanup() { debug("btif_sock_cleanup()"); + btsock_rfc_cleanup(); } static bt_status_t btsock_listen(btsock_type_t type, const char* service_name, const uint8_t* service_uuid, int channel, int* sock_fd, int flags) diff --git a/btif/src/btif_sock_rfc.c b/btif/src/btif_sock_rfc.c index b0d0538..dc62ea3 100644 --- a/btif/src/btif_sock_rfc.c +++ b/btif/src/btif_sock_rfc.c @@ -182,6 +182,18 @@ bt_status_t btsock_rfc_init(int poll_thread_handle) init_rfc_slots(); return BT_STATUS_SUCCESS; } +void btsock_rfc_cleanup() +{ + btsock_thread_exit(pth); + lock_slot(&slot_lock); + int i; + for(i = 0; i < MAX_RFC_CHANNEL; i++) + { + if(rfc_slots[i].id) + cleanup_rfc_slot(&rfc_slots[i]); + } + unlock_slot(&slot_lock); +} static inline rfc_slot_t* find_free_slot() { int i; @@ -512,6 +524,7 @@ static inline BOOLEAN send_app_scn(rfc_slot_t* rs) { return TRUE; } + return FALSE; } static BOOLEAN send_app_connect_signal(int fd, const bt_bdaddr_t* addr, int channel, int status, int send_fd) |