summaryrefslogtreecommitdiff
path: root/src/components/hmi_message_handler/src/mb_controller.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/components/hmi_message_handler/src/mb_controller.cc')
-rw-r--r--src/components/hmi_message_handler/src/mb_controller.cc21
1 files changed, 14 insertions, 7 deletions
diff --git a/src/components/hmi_message_handler/src/mb_controller.cc b/src/components/hmi_message_handler/src/mb_controller.cc
index d7fb432df2..871121fb4b 100644
--- a/src/components/hmi_message_handler/src/mb_controller.cc
+++ b/src/components/hmi_message_handler/src/mb_controller.cc
@@ -94,7 +94,13 @@ namespace NsMessageBroker
if(shutdown_) {
return;
}
- std::make_shared<WebsocketSession>(std::move(socket_), this)->Accept();
+ std::shared_ptr<WebsocketSession> ws_ptr = std::make_shared<WebsocketSession>(std::move(socket_), this);
+ ws_ptr->Accept();
+
+ mConnectionListLock.Acquire();
+ mConnectionList.push_back(ws_ptr);
+ mConnectionListLock.Release();
+
WaitForConnection();
}
@@ -190,14 +196,15 @@ namespace NsMessageBroker
}
void CMessageBrokerController::exitReceivingThread(){
- sync_primitives::AutoLock lock(mControllersListLock);
shutdown_ = true;
- std::map <std::string, WebsocketSession*>::iterator it;
- for(it = mControllersList.begin(); it != mControllersList.end(); it++) {
- if(!it->second->IsShuttingDown()) {
- it->second->Shutdown();
- }
+ mConnectionListLock.Acquire();
+ std::vector<std::shared_ptr<NsMessageBroker::WebsocketSession>>::iterator it;
+ for(it = mConnectionList.begin(); it != mConnectionList.end(); it++) {
+ (*it)->Shutdown();
+ mConnectionList.erase(it);
}
+ mConnectionListLock.Release();
+
boost::system::error_code ec;
socket_.close();
acceptor_.cancel(ec);