Signed-off-by: tomoaki <tomoaki@tomy-tech.com>
This commit is contained in:
tomoaki
2021-08-02 07:25:28 +09:00
parent 5fb4312aad
commit 4fc0e2f52b

View File

@@ -404,18 +404,16 @@ Client* ClientList::createClient(SensorNetAddress* addr, MQTTSNString* clientId,
Client* ClientList::createPredefinedTopic(MQTTSNString* clientId, string topicName, uint16_t topicId, bool aggregate) Client* ClientList::createPredefinedTopic(MQTTSNString* clientId, string topicName, uint16_t topicId, bool aggregate)
{ {
Client *client = nullptr;
if (topicId == 0) if (topicId == 0)
{ {
WRITELOG("Invalid TopicId. Predefined Topic %s, TopicId is 0. \n", topicName.c_str()); WRITELOG("Invalid TopicId. Predefined Topic %s, TopicId is 0. \n", topicName.c_str());
goto exit; return nullptr;
} }
if (strcmp(clientId->cstring, common_topic) == 0) if (strcmp(clientId->cstring, common_topic) == 0)
{ {
_gateway->getTopics()->add((const char*) topicName.c_str(), topicId); _gateway->getTopics()->add((const char*) topicName.c_str(), topicId);
goto exit; return nullptr;
} }
else else
{ {
@@ -423,20 +421,21 @@ Client* ClientList::createPredefinedTopic(MQTTSNString* clientId, string topicNa
if (_authorize && client == nullptr) if (_authorize && client == nullptr)
{ {
goto exit; return nullptr;
} }
client = createClient(NULL, clientId, aggregate); client = createClient(NULL, clientId, aggregate); // <=== BUGFIX
if (client) if (client == nullptr)
{ {
return nullptr;
}
// create Topic & Add it // create Topic & Add it
client->getTopics()->add((const char*) topicName.c_str(), topicId); client->getTopics()->add((const char*) topicName.c_str(), topicId);
client->_hasPredefTopic = true; client->_hasPredefTopic = true;
}
}
exit:
return client; return client;
} }
}
uint16_t ClientList::getClientCount() uint16_t ClientList::getClientCount()
{ {