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

VH-1279: Fix sonar reported bugs in MessageRouterBasic.cpp #588

Merged
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
4 changes: 1 addition & 3 deletions src/tmx/TmxCore/src/MessageRouterBasic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,9 @@ void MessageRouterBasic::broadcastMessage(MessageReceiver *sender, IvpMessage *m

//PerformanceTimer timer;

pthread_mutex_lock(&this->mMapLock);
pthread_mutex_lock(&this->mActiveBroadcastsLock);
this->mActiveBroadcasts++;
pthread_mutex_unlock(&this->mActiveBroadcastsLock);
pthread_mutex_unlock(&this->mMapLock);

int broadcastCount = 0;

Expand Down Expand Up @@ -107,7 +105,7 @@ void MessageRouterBasic::broadcastMessage(MessageReceiver *sender, IvpMessage *m
}
}
}

pthread_mutex_lock(&this->mActiveBroadcastsLock);
this->mActiveBroadcasts--;
pthread_mutex_unlock(&this->mActiveBroadcastsLock);
Expand Down
2 changes: 1 addition & 1 deletion src/tmx/TmxCore/src/MessageRouterBasic.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class MessageRouterBasic : public MessageRouter
* Keeps track of how many threads are actively inside the broadcast method in a thread safe manner (using mActiveBroadcastsLock).
* This is to allow concurrent execution of the broadcast, but give the register and unregister methods a way to tell when broadcasts are inactive.
*/
volatile int mActiveBroadcasts;
int mActiveBroadcasts;

/*!
* Used to keep the mActiveBroadcast count accurate since multiple thread's may be accessing.
Expand Down
Loading