kopia lustrzana https://github.com/espressif/esp-idf
bugfix:btmd fix the problem that fixed_queue_enqueue may give the wrong semaphore if list_append fail to calloc a new node
rodzic
cd68972e32
commit
87995c5f75
|
@ -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)
|
||||
|
|
|
@ -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;
|
||||
|
|
Ładowanie…
Reference in New Issue