summaryrefslogtreecommitdiff
path: root/src/components/connection_handler/src/heartbeat_monitor.cc
diff options
context:
space:
mode:
authorJackLivio <jack@livio.io>2018-10-19 15:05:09 -0400
committerGitHub <noreply@github.com>2018-10-19 15:05:09 -0400
commitd36316738785c96dab2ee892762ed08c059fffde (patch)
tree168a7c0705b5bc8f0dee7ce4b511ccf71759d9b4 /src/components/connection_handler/src/heartbeat_monitor.cc
parent7f7fcbb998fb17f2954fd103349af67ea9b71a3f (diff)
parent83c5e805346d55ec7fb9f4ba8b6f6855d992273e (diff)
downloadsdl_core-hotfix/templates_updates.tar.gz
Release 5.0.0
Diffstat (limited to 'src/components/connection_handler/src/heartbeat_monitor.cc')
-rw-r--r--src/components/connection_handler/src/heartbeat_monitor.cc21
1 files changed, 11 insertions, 10 deletions
diff --git a/src/components/connection_handler/src/heartbeat_monitor.cc b/src/components/connection_handler/src/heartbeat_monitor.cc
index f3a2322810..4c2d5899af 100644
--- a/src/components/connection_handler/src/heartbeat_monitor.cc
+++ b/src/components/connection_handler/src/heartbeat_monitor.cc
@@ -47,7 +47,6 @@ HeartBeatMonitor::HeartBeatMonitor(uint32_t heartbeat_timeout_mseconds,
Connection* connection)
: default_heartbeat_timeout_(heartbeat_timeout_mseconds)
, connection_(connection)
- , sessions_list_lock_(true)
, run_(true) {}
void HeartBeatMonitor::Process() {
@@ -90,18 +89,20 @@ void HeartBeatMonitor::threadMain() {
}
void HeartBeatMonitor::AddSession(uint8_t session_id) {
- LOG4CXX_DEBUG(logger_,
- "Add session with id " << static_cast<int32_t>(session_id));
+ const uint32_t converted_session_id = static_cast<int32_t>(session_id);
+ UNUSED(converted_session_id);
+ LOG4CXX_DEBUG(logger_, "Add session with id " << converted_session_id);
AutoLock auto_lock(sessions_list_lock_);
if (sessions_.end() != sessions_.find(session_id)) {
LOG4CXX_WARN(logger_,
- "Session with id " << static_cast<int32_t>(session_id)
- << " already exists");
+ "Session with id: " << converted_session_id
+ << " already exists");
return;
}
sessions_.insert(
std::make_pair(session_id, SessionState(default_heartbeat_timeout_)));
- LOG4CXX_INFO(logger_, "Start heartbeat for session " << session_id);
+ LOG4CXX_INFO(logger_,
+ "Start heartbeat for session: " << converted_session_id);
}
void HeartBeatMonitor::RemoveSession(uint8_t session_id) {
@@ -164,8 +165,8 @@ HeartBeatMonitor::SessionState::SessionState(
void HeartBeatMonitor::SessionState::RefreshExpiration() {
LOG4CXX_DEBUG(logger_, "Refresh expiration: " << heartbeat_timeout_mseconds_);
using namespace date_time;
- TimevalStruct time = DateTime::getCurrentTime();
- DateTime::AddMilliseconds(time, heartbeat_timeout_mseconds_);
+ date_time::TimeDuration time = getCurrentTime();
+ AddMilliseconds(time, heartbeat_timeout_mseconds_);
heartbeat_expiration_ = time;
}
@@ -194,8 +195,8 @@ void HeartBeatMonitor::SessionState::KeepAlive() {
}
bool HeartBeatMonitor::SessionState::HasTimeoutElapsed() {
- TimevalStruct now = date_time::DateTime::getCurrentTime();
- return date_time::DateTime::Greater(now, heartbeat_expiration_);
+ date_time::TimeDuration now = date_time::getCurrentTime();
+ return date_time::Greater(now, heartbeat_expiration_);
}
} // namespace connection_handler