Matt McCutchen's Web Site
/
rsync
/
rsync.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(from parent 1:
0857135
)
Rather than a loop subtracting 1e6 to convert usecs to secs/usecs, just
author
Martin Pool
<mbp@samba.org>
Tue, 9 Apr 2002 04:33:32 +0000
(
04:33
+0000)
committer
Martin Pool
<mbp@samba.org>
Tue, 9 Apr 2002 04:33:32 +0000
(
04:33
+0000)
use div/mod.
io.c
patch
|
blob
|
blame
|
history
diff --git
a/io.c
b/io.c
index
63df250
..
66fd4c8
100644
(file)
--- 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);
}