Skip to content

Commit

Permalink
JSONRPCLink: added missing lock and locking sequence also updated to …
Browse files Browse the repository at this point in the history
…avoid deadlock situations (#1783)
  • Loading branch information
HaseenaSainul authored Oct 25, 2024
1 parent 5c6afdf commit 75e5fe6
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions Source/websocket/JSONRPCLink.h
Original file line number Diff line number Diff line change
Expand Up @@ -227,16 +227,18 @@ namespace Thunder {
}
void Register(LinkType<INTERFACE>& client)
{
_adminLock.Lock();
typename std::list<LinkType<INTERFACE>* >::iterator index = std::find(_observers.begin(), _observers.end(), &client);
ASSERT(index == _observers.end());
if (index == _observers.end()) {
_observers.push_back(&client);
}

_adminLock.Unlock();

if (_channel.IsOpen() == true) {
client.Opened();
}

_adminLock.Unlock();
}
void Unregister(LinkType<INTERFACE>& client)
{
Expand All @@ -246,8 +248,9 @@ namespace Thunder {
if (index != _observers.end()) {
_observers.erase(index);
}
FactoryImpl::Instance().Revoke(&client);
_adminLock.Unlock();

FactoryImpl::Instance().Revoke(&client);
}
void Submit(const Core::ProxyType<INTERFACE>& message)
{
Expand Down

0 comments on commit 75e5fe6

Please sign in to comment.