diff options
author | dtrunov <dtrunov@luxoft.com> | 2015-12-07 14:10:41 +0200 |
---|---|---|
committer | dtrunov <dtrunov@luxoft.com> | 2016-02-03 16:30:52 +0200 |
commit | 011e0ede98c2936592f0744ad08e82b88c193cb8 (patch) | |
tree | ce0c2fc40a841faa07b5f2f14dc8f63ea65be9f4 /src/components/protocol_handler | |
parent | 5f932f4cc48f7020d2cb3a8f8ae37e989c57bf9b (diff) | |
download | sdl_core-011e0ede98c2936592f0744ad08e82b88c193cb8.tar.gz |
Fix dead locks if user register 30 and more applications
During processing this defect I found 3 dead locks in
components: conection_handler, hearbeat_monitor.
First deadlock:
First thread:
Calls KeepConnectionAlive() from connection_handler
in this method thread locked connection_list_lock_,
after that calls method KeepAlive() from heartbeat_monitor
and thread tries to lock sessions_list_lock_ wich was locked by
second thread
Second thread:
Blocks sessions_list_lock_ in method Process() from heartbeat_monitor
after that sends hearbeat to mobile
and calls method SendHeartBeat() from protocol_handler.
In this method calls ProtocolVersionUsed() where thread
tries to lock connection_list_lock_ wich was locked by
first thread -> DEAD LOCK
I fixed this problem using RWLock().
Second and third dead locks were associated with
time of action of sessions_list_lock in method Process()
from heartbeat_monitor
I decreased time of action this lock in order to
fix this problem.
Closes-bug:[APPLINK-19632](https://adc.luxoft.com/jira/browse/APPLINK-19632)
Diffstat (limited to 'src/components/protocol_handler')
-rw-r--r-- | src/components/protocol_handler/src/protocol_handler_impl.cc | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/src/components/protocol_handler/src/protocol_handler_impl.cc b/src/components/protocol_handler/src/protocol_handler_impl.cc index 1ca3642285..8c08afd4cc 100644 --- a/src/components/protocol_handler/src/protocol_handler_impl.cc +++ b/src/components/protocol_handler/src/protocol_handler_impl.cc @@ -319,15 +319,13 @@ void ProtocolHandlerImpl::SendHeartBeat(int32_t connection_id, LOG4CXX_AUTO_TRACE(logger_); uint8_t protocol_version; if (session_observer_->ProtocolVersionUsed(connection_id, - session_id, protocol_version)) { + session_id, protocol_version)) { ProtocolFramePtr ptr(new protocol_handler::ProtocolPacket(connection_id, - protocol_version, PROTECTION_OFF, FRAME_TYPE_CONTROL, + protocol_version, PROTECTION_OFF, FRAME_TYPE_CONTROL, SERVICE_TYPE_CONTROL, FRAME_DATA_HEART_BEAT, session_id, 0u, message_counters_[session_id]++)); - - raw_ford_messages_to_mobile_.PostMessage( - impl::RawFordMessageToMobile(ptr, false)); - LOG4CXX_DEBUG(logger_, "SendHeartBeat finished successfully"); + raw_ford_messages_to_mobile_.PostMessage(impl::RawFordMessageToMobile(ptr, false)); + LOG4CXX_DEBUG(logger_, "SendHeartBeat finished successfully"); } else { LOG4CXX_WARN(logger_, "SendHeartBeat is failed connection or session does not exist"); } |