diff --git a/include/queue.h b/include/queue.h index 37ad23c7e..89b5fb106 100644 --- a/include/queue.h +++ b/include/queue.h @@ -1491,6 +1491,10 @@ BaseType_t xQueueGiveMutexRecursive( QueueHandle_t xMutex ) PRIVILEGED_FUNCTION; * does not effect the number of queues, semaphores and mutexes that can be * created - just the number that the registry can hold. * + * If vQueueAddToRegistry is called more than once with the same xQueue + * parameter, the registry will store the pcQueueName parameter from the + * most recent call to vQueueAddToRegistry. + * * @param xQueue The handle of the queue being added to the registry. This * is the handle returned by a call to xQueueCreate(). Semaphore and mutex * handles can also be passed in here. diff --git a/queue.c b/queue.c index 6805cd050..2faa158e2 100644 --- a/queue.c +++ b/queue.c @@ -2730,24 +2730,37 @@ BaseType_t xQueueIsQueueFullFromISR( const QueueHandle_t xQueue ) configASSERT( xQueue ); configASSERT( pcQueueName ); + QueueRegistryItem_t * pxEntryToWrite = NULL; + /* See if there is an empty space in the registry. A NULL name denotes * a free slot. */ for( ux = ( UBaseType_t ) 0U; ux < ( UBaseType_t ) configQUEUE_REGISTRY_SIZE; ux++ ) { - if( xQueueRegistry[ ux ].pcQueueName == NULL ) + /* Replace an existing entry if the queue is already in the registry. */ + if( xQueueRegistry[ ux ].xHandle == xQueue ) { - /* Store the information on this queue. */ - xQueueRegistry[ ux ].pcQueueName = pcQueueName; - xQueueRegistry[ ux ].xHandle = xQueue; - - traceQUEUE_REGISTRY_ADD( xQueue, pcQueueName ); + pxEntryToWrite = &( xQueueRegistry[ ux ] ); break; } + /* Otherwise, store in the next empty location */ + else if( ( NULL == pxEntryToWrite ) && ( xQueueRegistry[ ux ].pcQueueName == NULL ) ) + { + pxEntryToWrite = &( xQueueRegistry[ ux ] ); + } else { mtCOVERAGE_TEST_MARKER(); } } + + if( NULL != pxEntryToWrite ) + { + /* Store the information on this queue. */ + pxEntryToWrite->pcQueueName = pcQueueName; + pxEntryToWrite->xHandle = xQueue; + + traceQUEUE_REGISTRY_ADD( xQueue, pcQueueName ); + } } #endif /* configQUEUE_REGISTRY_SIZE */