<html><head></head><body><div style="font-family: Verdana;font-size: 12.0px;"><div>
<div>Hello Daniel!</div>

<div> </div>

<div>We have managed to track the problem down.<br/>
What causes our troubles lies in the file timer.c in the function timer_handler.<br/>
Or to be more exact in the for-loop:</div>

<div> </div>

<div>for (prev_ticks=prev_ticks+1; prev_ticks!=saved_ticks; prev_ticks++)<br/>
  timer_run(prev_ticks);</div>

<div> </div>

<div>In our case, after the NTP time change, this tries to bring the prev_ticks (representing the year 1970) up to the saved_ticks (our current time provided by NTP) tick by tick.<br/>
This is quite some calculating for 45 years. Especially on an embedded device.</div>

<div> </div>

<div>As a workaround we have added an additional if-clause in the adjust_ticks function that simply ignores if the 'delta' between system time and ticks gets too high.<br/>
We have run a first test where this workaround seems to be ok but we'll run some further tests.</div>

<div> </div>

<div>Do you think this workaround might cause some problems? I.e. might there be a problem if the system time jumps ahead too far but we do not adjust the ticks?<br/>
(We hope not because a time-leap backwards is ignored too :) )</div>

<div> </div>

<div>Apart from our workaround:<br/>
Do you think there might be a way to handle this problem less CPU consuming (or to bring the ticks up to date in a bigger bulk)?</div>

<div> </div>

<div>Best regards,<br/>
Stefan</div>
<br/>
<div><br/>
<div name="quote" style="margin:10px 5px 5px 10px; padding: 10px 0 10px 10px; border-left:2px solid #C3D9E5; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">
<div style="margin:0 0 10px 0;"><b>Gesendet:</b> Donnerstag, 22. Oktober 2015 um 09:50 Uhr<br/>
<b>Von:</b> "Daniel-Constantin Mierla" <miconda@gmail.com><br/>
<b>An:</b> "Kamailio (SER) - Users Mailing List" <sr-users@lists.sip-router.org><br/>
<b>Betreff:</b> Re: [SR-Users] 100% CPU usage after NTP date update</div>

<div name="quoted-content">Hello,<br/>
<br/>
can you do 'top' and see what is the pid of the process using a lot of<br/>
cpu, then get the backtrace with gdb?<br/>
<br/>
gdb /path/to/kamailio PID<br/>
bt full<br/>
<br/>
It will help to see what kamailio is trying to do.<br/>
<br/>
Cheers,<br/>
Daniel<br/>
<br/>
On 22/10/15 10:45, Stefan Kohlhauser wrote:<br/>
> Hello everyone!<br/>
><br/>
> Setup:<br/>
> I am currently using a Kamailio 4.2.3 on an embedded device (low CPU and RAM). The device is not able to store the current date, so after a reboot its 1. Jan 1970 until NTP updates the date.<br/>
><br/>
> Problem:<br/>
> If the date is updated after the Kamailio has started (a leap of 45 years) the Kamailio uses up all the CPU and renders the device useless for a very long time.<br/>
><br/>
> Notes:<br/>
> There are no incomming requests at the time. (But the Kamailio is not responsive during that time anyway.)<br/>
> Adjusting the internal Kamailio-time seems to take longer when the date update leap is bigger.<br/>
><br/>
> My questions:<br/>
> 1) Can I prevent the Kamailio from using up the entire CPU after a date update? Or maybe do the internal ticks-update more gracefully?<br/>
> 2) For my better understanding: What happens within the Kamailio after adjust_ticks has updated the internal date?<br/>
><br/>
> Thanks in advance for your help!<br/>
><br/>
> Best regards,<br/>
> Stefan<br/>
><br/>
> _______________________________________________<br/>
> SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list<br/>
> sr-users@lists.sip-router.org<br/>
> <a href="http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users" target="_blank">http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users</a><br/>
<br/>
--<br/>
Daniel-Constantin Mierla<br/>
<a href="http://twitter.com/#!/miconda" target="_blank">http://twitter.com/#!/miconda</a> - <a href="http://www.linkedin.com/in/miconda" target="_blank">http://www.linkedin.com/in/miconda</a><br/>
Book: SIP Routing With Kamailio - <a href="http://www.asipto.com" target="_blank">http://www.asipto.com</a><br/>
<br/>
<br/>
_______________________________________________<br/>
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list<br/>
sr-users@lists.sip-router.org<br/>
<a href="http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users" target="_blank">http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users</a></div>
</div>
</div>
</div></div></body></html>