<html>
  <head>
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    Hello,<br>
    <br>
    thanks for troubleshooting this issue.<br>
    <br>
    Can you make a pull request on github.com kamailio project? Then we
    can review and analyze better the impact. Ultimately, we can make
    this a config options, as i think it is something good to have. The
    option could be the value after which the delta is ignored (because
    is too big) and timers jumps to execute current ticks.<br>
    <br>
    Cheers,<br>
    Daniel<br>
    <br>
    <div class="moz-cite-prefix">On 28/10/15 16:59, Stefan Kohlhauser
      wrote:<br>
    </div>
    <blockquote
cite="mid:trinity-c32eb785-2218-4e97-9a79-293b9b2dcf07-1446047951697@3capp-gmx-bs24"
      type="cite">
      <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"
                <a class="moz-txt-link-rfc2396E" href="mailto:miconda@gmail.com"><miconda@gmail.com></a><br>
                <b>An:</b> "Kamailio (SER) - Users Mailing List"
                <a class="moz-txt-link-rfc2396E" href="mailto:sr-users@lists.sip-router.org"><sr-users@lists.sip-router.org></a><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>
                > <a class="moz-txt-link-abbreviated" href="mailto:sr-users@lists.sip-router.org">sr-users@lists.sip-router.org</a><br>
                > <a moz-do-not-send="true"
                  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 moz-do-not-send="true"
                  href="http://twitter.com/#%21/miconda" target="_blank">http://twitter.com/#!/miconda</a>
                - <a moz-do-not-send="true"
                  href="http://www.linkedin.com/in/miconda"
                  target="_blank">http://www.linkedin.com/in/miconda</a><br>
                Book: SIP Routing With Kamailio - <a
                  moz-do-not-send="true" href="http://www.asipto.com"
                  target="_blank"><a class="moz-txt-link-freetext" href="http://www.asipto.com">http://www.asipto.com</a></a><br>
                <br>
                <br>
                _______________________________________________<br>
                SIP Express Router (SER) and Kamailio (OpenSER) -
                sr-users mailing list<br>
                <a class="moz-txt-link-abbreviated" href="mailto:sr-users@lists.sip-router.org">sr-users@lists.sip-router.org</a><br>
                <a moz-do-not-send="true"
                  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>
    </blockquote>
    <br>
    <pre class="moz-signature" cols="72">-- 
Daniel-Constantin Mierla
<a class="moz-txt-link-freetext" href="http://twitter.com/#!/miconda">http://twitter.com/#!/miconda</a> - <a class="moz-txt-link-freetext" href="http://www.linkedin.com/in/miconda">http://www.linkedin.com/in/miconda</a>
Book: SIP Routing With Kamailio - <a class="moz-txt-link-freetext" href="http://www.asipto.com">http://www.asipto.com</a>
Kamailio Advanced Training, Nov 30-Dec 2, Berlin - <a class="moz-txt-link-freetext" href="http://asipto.com/kat">http://asipto.com/kat</a></pre>
  </body>
</html>