Hi,

To begin with, I do call sys_check_timeouts() very often. I also tried
v2.0.1, where the problem vanishes. I believe it is fixed by the following
addition:

        } else if (timeout->time > msecs) {
          /* If this is the case, 'timeouts_last_time' and 'now' differs
too much.
             This can be due to sys_check_timeouts() not being called at
the right
             times, but also when stopping in a breakpoint. Anyway, let's
assume
             this is not wanted, so add the first timer's time instead of
'diff' */
          timeout->time = msecs + next_timeout->time;
        }
        timeout->next = t->next;

which looks more like a work-around for me, rather an actual fix.

I tried the snippet Sergio suggested and it correctly printed OK. So no
compiler issues.

The only thing that remains is to check the overflow of my sys_now()
function. I assume that it wraps around at 2^32-1, but I will cross check
it.




*Fotis Panagiotopoulos*

Mechatronics Engineer


*AMCO **Α**.**Β**.**Ε**.**Ε**.*

Αμφιαράου 25,, Τ.Κ. 104 42, Αθήνα, Ελλάδα
Τηλ : +30 210 5907000 – ext. 28 | Fax: +30 210 5912711
e-mail: [email protected] | web: http://www.amco.gr

*---------------------------------------------------------------------------*
Please consider the environment before printing this e-mail.
<http://www.amco.gr/>

On Fri, Feb 17, 2017 at 5:30 PM, Sergio R. Caprile <[email protected]>
wrote:

> Nope, the difference will be preserved by type promotion, unless the wrap
> around occurs more than once between calls or the counter counted more than
> half length counts (which also includes the former...).
> Are you calling frequently enough sys_check_timeouts() ?
> You should (read 'must').
>
> Otherwise, you have a compiler problem, try this:
> #include <stdio.h>
> #include <stdint.h>
>
> uint32_t now = 1;
> uint32_t timeouts_last_time = 0xFFFFFFFF;
>
> main()
> {
> uint32_t diff = now - timeouts_last_time;
>
>         printf("%u\n",diff);
>         if((now - timeouts_last_time) > 2)
>                 printf("Oops\n");
>         else
>                 printf("OK\n");
> }
>
> $ ./td
> 2
> OK
>
>
> _______________________________________________
> lwip-users mailing list
> [email protected]
> https://lists.nongnu.org/mailman/listinfo/lwip-users
>
_______________________________________________
lwip-users mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/lwip-users

Reply via email to