X-Git-Url: https://mattmccutchen.net/rsync/rsync.git/blobdiff_plain/08571358b19618268310c975448be5f49dd6c667..e681e8206641ec61d3ef8918f15351e8d84ccf4f:/io.c diff --git a/io.c b/io.c index 63df2504..66fd4c82 100644 --- a/io.c +++ b/io.c @@ -405,14 +405,14 @@ static void sleep_for_bwlimit(int bytes_written) if (!bwlimit) return; + + assert(bytes_written > 0); + assert(bwlimit > 0); - tv.tv_sec = 0; tv.tv_usec = bytes_written * 1000 / bwlimit; + tv.tv_sec = tv.tv_usec / 1000000; + tv.tv_usec = tv.tv_usec % 1000000; - while (tv.tv_usec > 1000000) { - tv.tv_sec++; - tv.tv_usec -= 1000000; - } select(0, NULL, NULL, NULL, tv); }