mirror of
https://github.com/RsyncProject/rsync.git
synced 2026-04-04 14:34:25 -04:00
Rather than a loop subtracting 1e6 to convert usecs to secs/usecs, just
use div/mod.
This commit is contained in:
14
io.c
14
io.c
@@ -405,14 +405,14 @@ static void sleep_for_bwlimit(int bytes_written)
|
||||
|
||||
if (!bwlimit)
|
||||
return;
|
||||
|
||||
tv.tv_sec = 0;
|
||||
tv.tv_usec = bytes_written * 1000 / bwlimit;
|
||||
|
||||
while (tv.tv_usec > 1000000) {
|
||||
tv.tv_sec++;
|
||||
tv.tv_usec -= 1000000;
|
||||
}
|
||||
assert(bytes_written > 0);
|
||||
assert(bwlimit > 0);
|
||||
|
||||
tv.tv_usec = bytes_written * 1000 / bwlimit;
|
||||
tv.tv_sec = tv.tv_usec / 1000000;
|
||||
tv.tv_usec = tv.tv_usec % 1000000;
|
||||
|
||||
select(0, NULL, NULL, NULL, tv);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user