Skip to content

Commit

Permalink
[acl]: Simplify AclOrch class locking schema. (#205)
Browse files Browse the repository at this point in the history
Lock mutex only at the beginning of critical sections.
  • Loading branch information
oleksandrivantsiv committed May 5, 2017
1 parent 2221cf6 commit 49c556c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 13 deletions.
12 changes: 4 additions & 8 deletions orchagent/aclorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -259,8 +259,6 @@ bool AclRule::create()
{
SWSS_LOG_ENTER();

unique_lock<mutex> lock(m_pAclOrch->getContextMutex());

sai_object_id_t table_oid = m_pAclOrch->getTableById(m_tableId);
vector<sai_attribute_t> rule_attrs;
sai_object_id_t range_objects[2];
Expand Down Expand Up @@ -357,8 +355,6 @@ bool AclRule::remove()
SWSS_LOG_ENTER();
sai_status_t res;

unique_lock<mutex> lock(m_pAclOrch->getContextMutex());

if (sai_acl_api->delete_acl_entry(m_ruleOid) != SAI_STATUS_SUCCESS)
{
SWSS_LOG_ERROR("Failed to delete ACL rule");
Expand Down Expand Up @@ -842,6 +838,8 @@ void AclOrch::update(SubjectType type, void *cntx)
return;
}

unique_lock<mutex> lock(m_countersMutex);

for (const auto& table : m_AclTables)
{
if (table.second.type != ACL_TABLE_MIRROR)
Expand All @@ -864,10 +862,12 @@ void AclOrch::doTask(Consumer &consumer)

if (table_name == APP_ACL_TABLE_NAME)
{
unique_lock<mutex> lock(m_countersMutex);
doAclTableTask(consumer);
}
else if (table_name == APP_ACL_RULE_TABLE_NAME)
{
unique_lock<mutex> lock(m_countersMutex);
doAclRuleTask(consumer);
}
else
Expand Down Expand Up @@ -1201,8 +1201,6 @@ sai_status_t AclOrch::createBindAclTable(AclTable &aclTable, sai_object_id_t &ta
{
SWSS_LOG_ENTER();

unique_lock<mutex> lock(m_countersMutex);

sai_status_t status;
sai_attribute_t attr;
vector<sai_attribute_t> table_attrs;
Expand Down Expand Up @@ -1294,8 +1292,6 @@ sai_status_t AclOrch::deleteUnbindAclTable(sai_object_id_t table_oid)
SWSS_LOG_ENTER();
sai_status_t status;

unique_lock<mutex> lock(m_countersMutex);

if ((status = bindAclTable(table_oid, m_AclTables[table_oid], false)) != SAI_STATUS_SUCCESS)
{
SWSS_LOG_ERROR("Failed to unbind table %s", m_AclTables[table_oid].description.c_str());
Expand Down
5 changes: 0 additions & 5 deletions orchagent/aclorch.h
Original file line number Diff line number Diff line change
Expand Up @@ -237,11 +237,6 @@ class AclOrch : public Orch, public Observer

sai_object_id_t getTableById(string table_id);

static mutex& getContextMutex()
{
return m_countersMutex;
}

static swss::Table& getCountersTable()
{
return m_countersTable;
Expand Down

0 comments on commit 49c556c

Please sign in to comment.