X-Git-Url: https://git.distorted.org.uk/u/mdw/putty/blobdiff_plain/f42faba9ff09df066a6bfce4e179d7566048395a..d719927eb175a73b13a7015498e9757010344bf5:/unix/uxsftp.c diff --git a/unix/uxsftp.c b/unix/uxsftp.c index a92cfc9d..f68685a0 100644 --- a/unix/uxsftp.c +++ b/unix/uxsftp.c @@ -443,7 +443,7 @@ static int ssh_sftp_do_select(int include_stdin, int no_fds_ok) fd_set rset, wset, xset; int i, fdcount, fdsize, *fdlist; int fd, fdstate, rwx, ret, maxfd; - long now = GETTICKCOUNT(); + unsigned long now = GETTICKCOUNT(); fdlist = NULL; fdcount = fdsize = 0; @@ -489,13 +489,17 @@ static int ssh_sftp_do_select(int include_stdin, int no_fds_ok) FD_SET_MAX(0, maxfd, rset); do { - long next, ticks; + unsigned long next, then; + long ticks; struct timeval tv, *ptv; if (run_timers(now, &next)) { - ticks = next - GETTICKCOUNT(); - if (ticks <= 0) - ticks = 1; /* just in case */ + then = now; + now = GETTICKCOUNT(); + if (now - then > next - then) + ticks = 0; + else + ticks = next - now; tv.tv_sec = ticks / 1000; tv.tv_usec = ticks % 1000 * 1000; ptv = &tv;