Merge pull request 'QueueMapManager bugfix' (#444) from mueller/queuemapmanager-bugfix into development

Reviewed-on: fsfw/fsfw#444
This commit is contained in:
Ulrich Mohr 2021-07-19 15:04:10 +02:00
commit ac146339a2
4 changed files with 16 additions and 4 deletions

View File

@ -17,7 +17,13 @@ QueueMapManager* QueueMapManager::instance() {
ReturnValue_t QueueMapManager::addMessageQueue(QueueHandle_t queue, MessageQueueId_t* id) {
MutexGuard lock(mapLock);
uint32_t currentId = queueCounter++;
uint32_t currentId = queueCounter;
queueCounter++;
if(currentId == MessageQueueIF::NO_QUEUE) {
// Skip the NO_QUEUE value
currentId = queueCounter;
queueCounter++;
}
auto returnPair = queueMap.emplace(currentId, queue);
if(not returnPair.second) {
#if FSFW_CPP_OSTREAM_ENABLED == 1

View File

@ -39,7 +39,7 @@ private:
QueueMapManager();
~QueueMapManager();
uint32_t queueCounter = 0;
uint32_t queueCounter = MessageQueueIF::NO_QUEUE + 1;
MutexIF* mapLock;
QueueMap queueMap;
static QueueMapManager* mqManagerInstance;

View File

@ -24,7 +24,13 @@ QueueMapManager* QueueMapManager::instance() {
ReturnValue_t QueueMapManager::addMessageQueue(
MessageQueueIF* queueToInsert, MessageQueueId_t* id) {
MutexGuard lock(mapLock);
uint32_t currentId = queueCounter++;
uint32_t currentId = queueCounter;
queueCounter++;
if(currentId == MessageQueueIF::NO_QUEUE) {
// Skip the NO_QUEUE value
currentId = queueCounter;
queueCounter++;
}
auto returnPair = queueMap.emplace(currentId, queueToInsert);
if(not returnPair.second) {
/* This should never happen for the atomic variable. */

View File

@ -41,7 +41,7 @@ private:
QueueMapManager();
~QueueMapManager();
uint32_t queueCounter = 0;
uint32_t queueCounter = MessageQueueIF::NO_QUEUE + 1;
MutexIF* mapLock;
QueueMap queueMap;
static QueueMapManager* mqManagerInstance;