X-Git-Url: https://git.distorted.org.uk/u/mdw/putty/blobdiff_plain/f42faba9ff09df066a6bfce4e179d7566048395a..d719927eb175a73b13a7015498e9757010344bf5:/windows/winsftp.c diff --git a/windows/winsftp.c b/windows/winsftp.c index e6b55c1d..d4c5fa6e 100644 --- a/windows/winsftp.c +++ b/windows/winsftp.c @@ -486,15 +486,20 @@ extern int select_result(WPARAM, LPARAM); int do_eventsel_loop(HANDLE other_event) { int n, nhandles, nallhandles, netindex, otherindex; - long next, ticks; + unsigned long next, then; + long ticks; HANDLE *handles; SOCKET *sklist; int skcount; - long now = GETTICKCOUNT(); + unsigned long now = GETTICKCOUNT(); if (run_timers(now, &next)) { - ticks = next - GETTICKCOUNT(); - if (ticks < 0) ticks = 0; /* just in case */ + then = now; + now = GETTICKCOUNT(); + if (now - then > next - then) + ticks = 0; + else + ticks = next - now; } else { ticks = INFINITE; }