Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix orchagent hang problem caused by erase operation on empty map #348

Merged
merged 1 commit into from
Oct 17, 2017
Merged
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
27 changes: 21 additions & 6 deletions orchagent/switchorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,22 +43,24 @@ void SwitchOrch::doTask(Consumer &consumer)

if (op == SET_COMMAND)
{
bool retry = false;

for (auto i : kfvFieldsValues(t))
{
auto attribute = fvField(i);

if (switch_attribute_map.find(attribute) == switch_attribute_map.end())
{
SWSS_LOG_ERROR("Unsupported switch attribute %s", attribute.c_str());
it = consumer.m_toSync.erase(it);
continue;
break;
}

auto value = fvValue(i);

sai_attribute_t attr;
attr.id = switch_attribute_map.at(attribute);

bool invalid_attr = false;
switch (attr.id)
{
case SAI_SWITCH_ATTR_FDB_UNICAST_MISS_PACKET_ACTION:
Expand All @@ -67,8 +69,8 @@ void SwitchOrch::doTask(Consumer &consumer)
if (packet_action_map.find(value) == packet_action_map.end())
{
SWSS_LOG_ERROR("Unsupported packet action %s", value.c_str());
it = consumer.m_toSync.erase(it);
continue;
invalid_attr = true;
break;
}
attr.value.s32 = packet_action_map.at(value);
break;
Expand All @@ -79,19 +81,32 @@ void SwitchOrch::doTask(Consumer &consumer)
break;

default:
invalid_attr = true;
break;
}
if (invalid_attr)
{
/* break from kfvFieldsValues for loop */
break;
}

sai_status_t status = sai_switch_api->set_switch_attribute(gSwitchId, &attr);
if (status != SAI_STATUS_SUCCESS)
{
SWSS_LOG_ERROR("Failed to set switch attribute %s to %s, rv:%d",
attribute.c_str(), value.c_str(), status);
it++;
continue;
retry = true;
break;
}

SWSS_LOG_NOTICE("Set switch attribute %s to %s", attribute.c_str(), value.c_str());
}
if (retry == true)
{
it++;
}
else
{
it = consumer.m_toSync.erase(it);
}
}
Expand Down