Skip to content

Commit

Permalink
fix deadlock caused by writing multiple values to simulink provider (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
jasondliu authored Jul 18, 2023
1 parent bf928e2 commit 4fe32c5
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/bennu/executables/bennu-simulink-provider/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ class BennuSimulinkProvider : public Provider
{
std::string result;

sem_wait(mUpdatesSemaphore);
for (auto &it : tags)
{
std::string tag{it.first};
Expand All @@ -236,7 +237,6 @@ class BennuSimulinkProvider : public Provider
// recieve write and format newDto
if (mDebug) { std::cout << "BennuSimulinkProvider::write ---- received write for tag: " << tag << " -- " << value << std::endl; }
std::scoped_lock<std::shared_mutex> lock(mLock);
sem_wait(mUpdatesSemaphore);
std::string dataStr, dataType;
if(value == "true" || value == "false")
{
Expand Down Expand Up @@ -268,13 +268,13 @@ class BennuSimulinkProvider : public Provider
break;
}
}
sem_post(mUpdatesSemaphore);

if (result.empty())
{
result += "ACK=Updated tags in Simulink provider";
}

sem_post(mUpdatesSemaphore);
return result;
}

Expand Down

0 comments on commit 4fe32c5

Please sign in to comment.