linphone-developers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Linphone-developers] [PATCH] Fix busy cycle if date change


From: Aymeric Moizard
Subject: Re: [Linphone-developers] [PATCH] Fix busy cycle if date change
Date: Thu, 7 May 2009 12:15:47 +0200 (CEST)




On Wed, 6 May 2009, damico wrote:

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 :)

This was fixed by using CLOCK_MONOTONIC instead of CLICK_REALTIME
some month ago I think. Did you experienced this with the latest
version? Can you check get_cur_time in msticker.c?

tks,
Aymeric MOIZARD / ANTISIP
amsip - http://www.antisip.com
osip2 - http://www.osip.org
eXosip2 - http://savannah.nongnu.org/projects/exosip/

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 mailing list
address@hidden
http://lists.nongnu.org/mailman/listinfo/linphone-developers





reply via email to

[Prev in Thread] Current Thread [Next in Thread]