Queueregistry check for duplicates

dreamsters wrote on Friday, October 18, 2019:

Hi

A sloppy copy/paste led me on to the fact that the queue registry can have the same queue be added twice into the xQueueRegistry array. There is also no check to compare current inserted queue names agains the queue name about to be added or any feedback that the queue about to be inserted cant be if the registry is already full. This was found in v10.2.1.

Could this perhaps change in the future?

Best regards
Martin

rtel wrote on Saturday, October 19, 2019:

Noted, however I’m not sure we would want to update this as it would
require searching the whole registry, especially if we were to also look
for duplicate string it may not be efficient. If we do it will probably
be with a configASSERT() so the check can be used at development time only.

richard_damon wrote on Saturday, October 19, 2019:

A couple of things to note about this. Nothing ‘breaks’ when you put a queue in the registry twice, you just waste a bit of space.

Also, and perhaps more importantly, I would very much dislike the registry rejecting adding two queue to the registry with the same name, as I frequently do this. A device driver may need multiple queue (and incoming queue, and outgoing queue, a mutex, and maybe a semaphore). You may have multiple similar devices, so you create a common driver which you initialize with parameters, including a name, which it uses on the various queues. It would be more work to make unique names for each queue used by the device, and you can usually distinguish which is which by that attributes of the queue.

dreamsters wrote on Monday, October 21, 2019:

Hi again.

For my own purposes, I will change the add function to something similar to this.

	BaseType_t xQueueAddToRegistry( QueueHandle_t xQueue, const char *pcQueueName ) /*lint !e971 Unqualified char types are allowed for strings and single characters only. */
	{
	UBaseType_t ux;
    BaseType_t xReturn = pdFALSE;
		/* 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) || (xQueueRegistry[ ux ].xHandle == xQueue))
			{
				/* Store the information on this queue. */
				xQueueRegistry[ ux ].pcQueueName = pcQueueName;
				xQueueRegistry[ ux ].xHandle = xQueue;
                xReturn = pdTRUE;
				traceQUEUE_REGISTRY_ADD( xQueue, pcQueueName );
				break;
			}
			else
			{
				mtCOVERAGE_TEST_MARKER();
			}
		}
        return xReturn;
	}

This will

  • Only insert a queue once
  • Update a queues name if needed
  • Inform the caller if the queue is now inserted into the registry

This is currently compleatly untested as I am currently out of office.

// Martin

Im bringing this up again as i noticed that the API has changed (in at least 10.3.1)and that the function now no longer returns if it was successful or not. ’

I find the change perplexing. How will i know if calls to vQueueAddToRegistry actually inserted into the array?

// Martin

To my knowledge that API has not changed in a long time. Agree it does seem deficient in that it does not let you know if the queue was added to the registry or not.

Ofcourse it has not.
That code was my changes to the implementation :unamused:.

So sorry to have bother you with it.

// Martin