summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAaron <aaron@10gen.com>2009-04-03 15:34:44 -0400
committerAaron <aaron@10gen.com>2009-04-03 15:34:44 -0400
commit80c3078d1a15c5e9aeddcff198defada836a3fc6 (patch)
tree945967a27dd2fdd18c243468c0ea35ce1fbf0524
parentebaf4292d6a78eb84ef027380beedb829b278082 (diff)
downloadmongo-80c3078d1a15c5e9aeddcff198defada836a3fc6.tar.gz
fix sleepmillis
-rw-r--r--util/goodies.h11
1 files changed, 6 insertions, 5 deletions
diff --git a/util/goodies.h b/util/goodies.h
index 38e10b48e39..55dd4b89bf1 100644
--- a/util/goodies.h
+++ b/util/goodies.h
@@ -176,11 +176,12 @@ namespace mongo {
inline void sleepmillis(int s) {
boost::xtime xt;
boost::xtime_get(&xt, boost::TIME_UTC);
- if( s >= 1000 ) {
- xt.sec += s/1000;
- s-=1000;
- }
- xt.nsec += s * 1000000;
+ xt.sec += ( s / 1000 );
+ xt.nsec += ( s % 1000 ) * 1000000;
+ if ( xt.nsec >= 1000000000 ) {
+ xt.nsec -= 1000000000;
+ xt.sec++;
+ }
boost::thread::sleep(xt);
}
// note this wraps