lwip-users
[Top][All Lists]
Advanced

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

Re: [lwip-users] Timeout wraparound bug


From: Sergio R. Caprile
Subject: Re: [lwip-users] Timeout wraparound bug
Date: Fri, 17 Feb 2017 12:30:54 -0300
User-agent: Mozilla/5.0 (Windows NT 6.1; rv:45.0) Gecko/20100101 Thunderbird/45.7.1

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




reply via email to

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