Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 8 additions & 9 deletions orchagent/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ extern "C" {
#include <iostream>
#include <unordered_map>
#include <map>
#include <memory>
#include <thread>
#include <chrono>
#include <getopt.h>
Expand Down Expand Up @@ -251,16 +252,16 @@ int main(int argc, char **argv)
DBConnector config_db(CONFIG_DB, DBConnector::DEFAULT_UNIXSOCKET, 0);
DBConnector state_db(STATE_DB, DBConnector::DEFAULT_UNIXSOCKET, 0);

OrchDaemon *orchDaemon = new OrchDaemon(&appl_db, &config_db, &state_db);
if (!orchDaemon->init())
{
SWSS_LOG_ERROR("Failed to initialize orchstration daemon");
delete orchDaemon;
exit(EXIT_FAILURE);
}
auto orchDaemon = make_shared<OrchDaemon>(&appl_db, &config_db, &state_db);

try
{
if (!orchDaemon->init())
{
SWSS_LOG_ERROR("Failed to initialize orchstration daemon");
exit(EXIT_FAILURE);
}

SWSS_LOG_NOTICE("Notify syncd APPLY_VIEW");

attr.id = SAI_REDIS_SWITCH_ATTR_NOTIFY_SYNCD;
Expand All @@ -270,7 +271,6 @@ int main(int argc, char **argv)
if (status != SAI_STATUS_SUCCESS)
{
SWSS_LOG_ERROR("Failed to notify syncd APPLY_VIEW %d", status);
delete orchDaemon;
exit(EXIT_FAILURE);
}

Expand All @@ -285,6 +285,5 @@ int main(int argc, char **argv)
SWSS_LOG_ERROR("Failed due to exception: %s", e.what());
}

delete orchDaemon;
return 0;
}
8 changes: 7 additions & 1 deletion orchagent/orch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -471,9 +471,15 @@ void Orch::addConsumer(DBConnector *db, string tableName, int pri)

void Orch::addExecutor(string executorName, Executor* executor)
{
m_consumerMap.emplace(std::piecewise_construct,
auto inserted = m_consumerMap.emplace(std::piecewise_construct,
std::forward_as_tuple(executorName),
std::forward_as_tuple(executor));

// If there is duplication of executorName in m_consumerMap, logic error
if (!inserted.second)
{
SWSS_LOG_THROW("Duplicated executorName in m_consumerMap: %s", executorName.c_str());
}
}

Executor *Orch::getExecutor(string executorName)
Expand Down