[Top][All Lists]

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

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

From: damico
Subject: Re: [Linphone-developers] [PATCH] Fix busy cycle if date change
Date: Thu, 07 May 2009 14:30:39 +0200
User-agent: Mozilla-Thunderbird (X11/20090103)

Hi Aymeric,
unfortunately on my uClibc version (9.27) CLOCK_MONOTONIC was not implemented yet. It was introduced from 9.28. So, now I must use my patch and I can't test your (best) solution; but I'm quite sure that CLOCK_MONOTONIC is the real fix and my code just a work around.

A note: maybe should be better check if CLOCK_MONOTONIC is implemented before use it as exclusive source of time in linux system...


damico ha scritto:
Hi Aymeric,

I'm using mediastreamer 2.2.0 and, as you said, it uses CLOCK_REALTIME instead of CLOCK_MONOTONIC.

I'll try to change it and check if the problem disappears... I can't upgrade mediastreamer now but I'll upgrade it to the last version at soon as possible.

What is the last version of mediastreamer? There is a "bugs list" and/or "new features list" for the last version of mediastreamer?



Aymeric Moizard ha scritto:

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?

amsip -
osip2 -
eXosip2 -

I'm proposing that code to solve the problem... any comments?



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 @@
- 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;
+            }
-            diff=s->time-realtime;
           if (diff>0){
               /* sleep until next tick */

Linphone-developers mailing list

Linphone-developers mailing list

reply via email to

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