summaryrefslogtreecommitdiffstats
path: root/btif/src/btif_profile_queue.c
diff options
context:
space:
mode:
authorZach Johnson <zachoverflow@google.com>2014-12-03 15:18:49 -0800
committerAndre Eisenbach <eisenbach@google.com>2015-03-16 16:51:40 -0700
commit2487018e0ad31e8962eed0131be08b27dde5d25c (patch)
tree92c3c7144ef468a8d7835e2f3696ef4f7abe79be /btif/src/btif_profile_queue.c
parent5cf03367ac9ba6cb41bc1531f95eae7bcaa97d44 (diff)
downloadandroid_system_bt-2487018e0ad31e8962eed0131be08b27dde5d25c.tar.gz
android_system_bt-2487018e0ad31e8962eed0131be08b27dde5d25c.tar.bz2
android_system_bt-2487018e0ad31e8962eed0131be08b27dde5d25c.zip
ungkibufferize the profile queue, use assert
ASSERTC isn't a real assert. It just prints a message and allows the code to carry on. Switch to asserts so the exception condition is evident in the crash log. Make the profile queue use osi_malloc/free instead of gki buffers, so it can't drain the buffer pool.
Diffstat (limited to 'btif/src/btif_profile_queue.c')
-rw-r--r--btif/src/btif_profile_queue.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/btif/src/btif_profile_queue.c b/btif/src/btif_profile_queue.c
index 5dbe8f2b7..fe78b84e4 100644
--- a/btif/src/btif_profile_queue.c
+++ b/btif/src/btif_profile_queue.c
@@ -24,6 +24,7 @@
*
******************************************************************************/
+#include <assert.h>
#include <hardware/bluetooth.h>
#define LOG_TAG "BTIF_QUEUE"
@@ -31,6 +32,7 @@
#include "btif_profile_queue.h"
#include "gki.h"
#include "list.h"
+#include "osi/include/allocator.h"
#include "stack_manager.h"
/*******************************************************************************
@@ -55,21 +57,26 @@ typedef struct {
static list_t *connect_queue;
+static const size_t MAX_REASONABLE_REQUESTS = 10;
+
/*******************************************************************************
** Queue helper functions
*******************************************************************************/
static void queue_int_add(connect_node_t *p_param) {
- connect_node_t *p_node = GKI_getbuf(sizeof(connect_node_t));
- ASSERTC(p_node != NULL, "Failed to allocate new list node", 0);
+ connect_node_t *p_node = osi_malloc(sizeof(connect_node_t));
+ assert(p_node != NULL);
memcpy(p_node, p_param, sizeof(connect_node_t));
if (!connect_queue) {
- connect_queue = list_new(GKI_freebuf);
- ASSERTC(connect_queue != NULL, "Failed to allocate list", 0);
+ connect_queue = list_new(osi_free);
+ assert(connect_queue != NULL);
}
+ // Sanity check to make sure we're not leaking connection requests
+ assert(list_length(connect_queue) < MAX_REASONABLE_REQUESTS);
+
list_append(connect_queue, p_node);
}