aboutsummaryrefslogtreecommitdiff
path: root/lib/base
diff options
context:
space:
mode:
authorFelix Domke <tmbinc@elitedvb.net>2005-11-22 16:53:20 +0000
committerFelix Domke <tmbinc@elitedvb.net>2005-11-22 16:53:20 +0000
commitccd9b3814f5736e32f689e37ba7f870d6a1066cd (patch)
tree3baf021dc7f653303dd62ad0e30e59a5d053a84e /lib/base
parent7c531362f5e50a36fa2ca8026f87b95d04807673 (diff)
downloadenigma2-ccd9b3814f5736e32f689e37ba7f870d6a1066cd.tar.gz
enigma2-ccd9b3814f5736e32f689e37ba7f870d6a1066cd.zip
invalidate local time if time was changed
Diffstat (limited to 'lib/base')
-rw-r--r--lib/base/ebase.cpp9
-rw-r--r--lib/base/ebase.h3
2 files changed, 11 insertions, 1 deletions
diff --git a/lib/base/ebase.cpp b/lib/base/ebase.cpp
index 7951f6e7..7f84cc91 100644
--- a/lib/base/ebase.cpp
+++ b/lib/base/ebase.cpp
@@ -59,7 +59,7 @@ void eTimer::startLongTimer( int seconds )
bActive = bSingleShot = true;
interval = 0;
gettimeofday(&nextActivation, 0);
-// eDebug("this = %p\nnow sec = %d, usec = %d\nadd %d msec", this, nextActivation.tv_sec, nextActivation.tv_usec, msek);
+// eDebug("this = %p\nnow sec = %d, usec = %d\nadd %d sec", this, nextActivation.tv_sec, nextActivation.tv_usec, seconds);
if ( seconds > 0 )
nextActivation.tv_sec += seconds;
// eDebug("next Activation sec = %d, usec = %d", nextActivation.tv_sec, nextActivation.tv_usec );
@@ -160,6 +160,7 @@ void eMainloop::processOneEvent()
/* get current time */
timeval now;
gettimeofday(&now, 0);
+ m_now_is_invalid = 0;
int poll_timeout = -1; /* infinite in case of empty timer list */
@@ -228,6 +229,11 @@ void eMainloop::processOneEvent()
{
singleLock s(recalcLock);
+ /* this will never change while we have the recalcLock */
+ /* we can savely return here, the timer will be re-checked soon. */
+ if (m_now_is_invalid)
+ return;
+
/* process all timers which are ready. first remove them out of the list. */
while ((!m_timer_list.empty()) && (m_timer_list.begin()->getNextActivation() < now))
m_timer_list.begin()->activate();
@@ -294,6 +300,7 @@ void eMainloop::addTimeOffset(int offset)
;it != eMainloop::existing_loops.end(); ++it)
{
singleLock s(it->recalcLock);
+ it->m_now_is_invalid = 1;
for (ePtrList<eTimer>::iterator tit = it->m_timer_list.begin(); tit != it->m_timer_list.end(); ++tit )
tit->addTimeOffset(offset);
}
diff --git a/lib/base/ebase.h b/lib/base/ebase.h
index 54b4063b..2a1fe628 100644
--- a/lib/base/ebase.h
+++ b/lib/base/ebase.h
@@ -176,6 +176,8 @@ class eMainloop
void processOneEvent();
int retval;
pthread_mutex_t recalcLock;
+
+ int m_now_is_invalid;
public:
static void addTimeOffset(int offset);
void addSocketNotifier(eSocketNotifier *sn);
@@ -187,6 +189,7 @@ public:
eMainloop()
:app_quit_now(0),loop_level(0),retval(0)
{
+ m_now_is_invalid = 0;
existing_loops.push_back(this);
pthread_mutex_init(&recalcLock, 0);
}