Skip to content

Commit

Permalink
Merge pull request #22 from salesforce/fix-init-mutex
Browse files Browse the repository at this point in the history
  • Loading branch information
twarit-waikar authored Mar 25, 2022
2 parents f8c8b2c + a34de63 commit 4604d0a
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions p4-fusion/p4_api.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,10 @@ std::mutex P4API::InitializationMutex;

P4API::P4API()
{
if (!Initialize())
{
// Helix Core C++ API seems to crash while making connections parallely.
// Although, this function is not currently accessed in parallel, it can
// be during retries.
std::unique_lock<std::mutex> lock(InitializationMutex);
if (!Initialize())
{
ERR("Could not initialize P4API");
return;
}
ERR("Could not initialize P4API");
return;
}

AddClientSpecView(ClientSpec.mapping);
Expand All @@ -40,6 +34,9 @@ bool P4API::Initialize()
{
MTR_SCOPE("P4", __func__);

// Helix Core C++ API seems to crash while making connections parallely.
std::unique_lock<std::mutex> lock(InitializationMutex);

Error e;
StrBuf msg;

Expand Down

0 comments on commit 4604d0a

Please sign in to comment.