summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArtem Nosach <ANosach@luxoft.com>2015-04-26 16:28:15 +0300
committerArtem Nosach <ANosach@luxoft.com>2015-06-23 17:06:28 +0300
commit44cea52d68fd61615cf6d56693ffee7bcfba32dd (patch)
treeb5b761a2b6b86f0bef7dbfe47fceedd1ef40c072
parent794783b5d3676339ca66f5ecebb5f7aff907c70c (diff)
downloadsmartdevicelink-44cea52d68fd61615cf6d56693ffee7bcfba32dd.tar.gz
Close session correctly even with kMalformed reason.
-rw-r--r--src/components/connection_handler/src/connection_handler_impl.cc23
1 files changed, 13 insertions, 10 deletions
diff --git a/src/components/connection_handler/src/connection_handler_impl.cc b/src/components/connection_handler/src/connection_handler_impl.cc
index ac5b9f850..017ac2f90 100644
--- a/src/components/connection_handler/src/connection_handler_impl.cc
+++ b/src/components/connection_handler/src/connection_handler_impl.cc
@@ -770,7 +770,9 @@ void ConnectionHandlerImpl::CloseSession(ConnectionHandle connection_handle,
LOG4CXX_AUTO_TRACE(logger_);
LOG4CXX_DEBUG(logger_, "Closing session with id: " << session_id);
- if (protocol_handler_) {
+ // In case of malformed message the connection should be broke up without
+ // any other notification to mobile.
+ if (close_reason != kMalformed && protocol_handler_) {
protocol_handler_->SendEndSession(connection_handle, session_id);
}
@@ -784,9 +786,7 @@ void ConnectionHandlerImpl::CloseSession(ConnectionHandle connection_handle,
ConnectionList::iterator connection_list_itr =
connection_list_.find(connection_id);
if (connection_list_.end() != connection_list_itr) {
- if (connection_handler_observer_ && kCommon == close_reason) {
- session_map = connection_list_itr->second->session_map();
- }
+ session_map = connection_list_itr->second->session_map();
connection_list_itr->second->RemoveSession(session_id);
} else {
LOG4CXX_ERROR(logger_, "Connection with id: " << connection_id
@@ -795,6 +795,11 @@ void ConnectionHandlerImpl::CloseSession(ConnectionHandle connection_handle,
}
}
+ if (!connection_handler_observer_) {
+ LOG4CXX_ERROR(logger_, "Connection handler observer not found");
+ return;
+ }
+
SessionMap::const_iterator session_map_itr = session_map.find(session_id);
if (session_map_itr != session_map.end()) {
const uint32_t session_key = KeyFromPair(connection_id, session_id);
@@ -805,16 +810,14 @@ void ConnectionHandlerImpl::CloseSession(ConnectionHandle connection_handle,
for (;service_list_itr != service_list.end(); ++service_list_itr) {
const protocol_handler::ServiceType service_type =
service_list_itr->service_type;
- connection_handler_observer_->OnServiceEndedCallback(
- session_key, service_type, close_reason);
+ connection_handler_observer_->OnServiceEndedCallback(session_key,
+ service_type);
}
} else {
- LOG4CXX_ERROR(logger_, "Session with id: " << session_id
- << " not found");
- session_map.clear();
+ LOG4CXX_ERROR(logger_, "Session with id: "
+ << session_id << " not found");
return;
}
- session_map.clear();
LOG4CXX_DEBUG(logger_, "Session with id: " << session_id
<< " has been closed successfully");
}