>-        if ((dwTimeout != INFINITE) && (start_time + dwTimeout >= now))
>+        if ((dwTimeout != INFINITE) && (now >= start_time + dwTimeout))

>From time immemorial, it has been drummed into me
that one should always handle wraparound when
checking timers.  So something like
    DWORD delta = now - start_time;
    if (dwTimeout != INFINITE) && (delta < 0x80000000UL) && (delta > dwTimeout))
might be more correct... I used to always use
a signed variable for this, but C compilers
now treat overflow of signed variables as
a conceptual error, so the subtraction has to be unsigned,
There's probably a cleaner way to code this,
but doing the subtraction to get the delta time,
and then comparing against the maximum desired
delta time, is the way to avoid trouble at rollover.
- Dan


Reply via email to