Merge branch 'bugfix/btdm_osi_queue_gycfix_master' into 'master'

Component/bt : Added handling of osi memory calloc failure

See merge request espressif/esp-idf!6140
This commit is contained in:
Jiang Jiang Jian 2019-10-14 21:35:41 +08:00
commit bf87d0949b
2 changed files with 9 additions and 4 deletions

View File

@ -129,6 +129,8 @@ size_t fixed_queue_capacity(fixed_queue_t *queue)
bool fixed_queue_enqueue(fixed_queue_t *queue, void *data, uint32_t timeout)
{
bool status=false; //Flag whether enqueued success
assert(queue != NULL);
assert(data != NULL);
@ -137,13 +139,13 @@ bool fixed_queue_enqueue(fixed_queue_t *queue, void *data, uint32_t timeout)
}
osi_mutex_lock(&queue->lock, OSI_MUTEX_MAX_TIMEOUT);
list_append(queue->list, data);
status = list_append(queue->list, data); //Check whether enqueued success
osi_mutex_unlock(&queue->lock);
osi_sem_give(&queue->dequeue_sem);
if(status == true )
osi_sem_give(&queue->dequeue_sem);
return true;
return status;
}
void *fixed_queue_dequeue(fixed_queue_t *queue, uint32_t timeout)

View File

@ -102,6 +102,7 @@ bool list_insert_after(list_t *list, list_node_t *prev_node, void *data) {
assert(data != NULL);
list_node_t *node = (list_node_t *)osi_calloc(sizeof(list_node_t));
if (!node) {
OSI_TRACE_ERROR("%s osi_calloc failed.\n", __FUNCTION__ );
return false;
}
node->next = prev_node->next;
@ -120,6 +121,7 @@ bool list_prepend(list_t *list, void *data)
assert(data != NULL);
list_node_t *node = (list_node_t *)osi_calloc(sizeof(list_node_t));
if (!node) {
OSI_TRACE_ERROR("%s osi_calloc failed.\n", __FUNCTION__ );
return false;
}
node->next = list->head;
@ -138,6 +140,7 @@ bool list_append(list_t *list, void *data)
assert(data != NULL);
list_node_t *node = (list_node_t *)osi_calloc(sizeof(list_node_t));
if (!node) {
OSI_TRACE_ERROR("%s osi_calloc failed.\n", __FUNCTION__ );
return false;
}
node->next = NULL;