[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Linphone-developers] [PATCH] Fix busy cycle if date change
From: |
damico |
Subject: |
[Linphone-developers] [PATCH] Fix busy cycle if date change |
Date: |
Wed, 06 May 2009 18:46:06 +0200 |
User-agent: |
Mozilla-Thunderbird 2.0.0.19 (X11/20090103) |
Hi all,
i found a issue when date change and a ticker running:
If the date move backward the ticker thread become a busy cycle. On my
embedded solution that use an ntp server that issue causes a lot of
disasters :)
I'm proposing that code to solve the problem... any comments?
Regards
--Michele
Index: mediastreamer2/src/msticker.c
===================================================================
--- mediastreamer2/src/msticker.c (revision 463)
+++ mediastreamer2/src/msticker.c (working copy)
@@ -331,6 +331,8 @@
#ifndef WIN32_TIMERS
+#define _MAX_DELAY_FOR_SYNC_FORCE_MS (1*60*1000) /* 1 min */
+
void * ms_ticker_run(void *arg)
{
uint64_t realtime;
@@ -352,9 +354,19 @@
run_graphs(s,s->execution_list,FALSE);
s->time+=s->interval;
while(1){
- realtime=s->get_cur_time_ptr(s->get_cur_time_data)-s->orig;
+ uint64_t now = s->get_cur_time_ptr(s->get_cur_time_data);
+ if (now < s->orig){
+ ms_warning("Back from the future....Sync");
+ s->orig = now - s->time;
+ }
+ realtime = now - s->orig;
+ diff = s->time - realtime;
+ if (diff < -_MAX_DELAY_FOR_SYNC_FORCE_MS || diff >
_MAX_DELAY_FOR_SYNC_FORCE_MS){
+ ms_warning("... Too much diff (does date be changed
forward?)....Sync");
+ s->orig=now - s->time;
+ diff = 0;
+ }
ms_mutex_unlock(&s->lock);
- diff=s->time-realtime;
if (diff>0){
/* sleep until next tick */
sleepMs((int)diff);
- [Linphone-developers] [PATCH] Fix busy cycle if date change,
damico <=