summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAGaliuzov <AGaliuzov@luxoft.com>2015-08-28 16:04:02 +0300
committerAGaliuzov <AGaliuzov@luxoft.com>2015-08-28 16:04:02 +0300
commite9e9e14eb9348558420c534bb88eed7a5234343b (patch)
tree3b9dd1d77ce6dc2fddef0f63f020b1fac40259f5
parentfe37e1cd17d85c75693e99906acdaecbc771b2ff (diff)
parent0f51298e1da6b16f980ca047048bee4433df2e56 (diff)
downloadsmartdevicelink-e9e9e14eb9348558420c534bb88eed7a5234343b.tar.gz
Merge pull request #174 from LuxoftSDL/genivi_APPLINK-11950
Genivi applink 11950
-rw-r--r--src/components/connection_handler/include/connection_handler/heartbeat_monitor.h4
-rw-r--r--src/components/connection_handler/src/heartbeat_monitor.cc5
-rw-r--r--src/components/include/utils/message_queue.h7
-rw-r--r--src/components/media_manager/src/pipe_streamer_adapter.cc2
4 files changed, 12 insertions, 6 deletions
diff --git a/src/components/connection_handler/include/connection_handler/heartbeat_monitor.h b/src/components/connection_handler/include/connection_handler/heartbeat_monitor.h
index 4df0fd19f..0233e269d 100644
--- a/src/components/connection_handler/include/connection_handler/heartbeat_monitor.h
+++ b/src/components/connection_handler/include/connection_handler/heartbeat_monitor.h
@@ -83,7 +83,8 @@ class HeartBeatMonitor: public threads::ThreadDelegate {
// \brief Connection that must be closed when timeout elapsed
Connection *connection_;
- static const int32_t kDefaultCycleTimeout = 100000;
+ //Default HeartBeat cycle timeout (in miliseconds)
+ static const int32_t kDefaultCycleTimeout = 100;
class SessionState {
public:
@@ -110,6 +111,7 @@ class HeartBeatMonitor: public threads::ThreadDelegate {
sync_primitives::Lock sessions_list_lock_; // recurcive
sync_primitives::Lock main_thread_lock_;
mutable sync_primitives::Lock heartbeat_timeout_seconds_lock_;
+ sync_primitives::ConditionalVariable heartbeat_monitor_;
volatile bool run_;
diff --git a/src/components/connection_handler/src/heartbeat_monitor.cc b/src/components/connection_handler/src/heartbeat_monitor.cc
index fdb3208d0..2349e0589 100644
--- a/src/components/connection_handler/src/heartbeat_monitor.cc
+++ b/src/components/connection_handler/src/heartbeat_monitor.cc
@@ -81,7 +81,7 @@ void HeartBeatMonitor::threadMain() {
logger_,
"Start heart beat monitor. Timeout is " << default_heartbeat_timeout_);
while (run_) {
- usleep(kDefaultCycleTimeout);
+ heartbeat_monitor_.WaitFor(main_lock, kDefaultCycleTimeout);
Process();
}
}
@@ -128,8 +128,9 @@ void HeartBeatMonitor::exitThreadMain() {
// FIXME (dchmerev@luxoft.com): thread requested to stop should stop as soon as possible,
// not running one more iteration before actual stop
LOG4CXX_AUTO_TRACE(logger_);
- run_ = false;
AutoLock main_lock(main_thread_lock_);
+ run_ = false;
+ heartbeat_monitor_.NotifyOne();
}
void HeartBeatMonitor::set_heartbeat_timeout_seconds(int32_t timeout,
diff --git a/src/components/include/utils/message_queue.h b/src/components/include/utils/message_queue.h
index a187328e1..e0b333672 100644
--- a/src/components/include/utils/message_queue.h
+++ b/src/components/include/utils/message_queue.h
@@ -158,11 +158,12 @@ template<typename T, class Q> void MessageQueue<T, Q>::push(const T& element) {
{
sync_primitives::AutoLock auto_lock(queue_lock_);
if (shutting_down_) {
- CREATE_LOGGERPTR_LOCAL(logger_, "Utils")
- LOG4CXX_ERROR(logger_, "Runtime error, pushing into queue"
+ CREATE_LOGGERPTR_LOCAL(logger_, "Utils")
+ LOG4CXX_ERROR(logger_, "Runtime error, pushing into queue"
" that is being shut down");
+ return;
}
- queue_.push(element);
+ queue_.push(element);
}
queue_new_items_.Broadcast();
}
diff --git a/src/components/media_manager/src/pipe_streamer_adapter.cc b/src/components/media_manager/src/pipe_streamer_adapter.cc
index b3f94a6e0..5990428c6 100644
--- a/src/components/media_manager/src/pipe_streamer_adapter.cc
+++ b/src/components/media_manager/src/pipe_streamer_adapter.cc
@@ -108,6 +108,8 @@ void PipeStreamerAdapter::StopActivity(int32_t application_key) {
is_ready_ = false;
current_application_ = 0;
+ messages_.Reset();
+
for (std::set<MediaListenerPtr>::iterator it = media_listeners_.begin();
media_listeners_.end() != it;
++it) {