From 80c3078d1a15c5e9aeddcff198defada836a3fc6 Mon Sep 17 00:00:00 2001 From: Aaron Date: Fri, 3 Apr 2009 15:34:44 -0400 Subject: [PATCH] fix sleepmillis --- util/goodies.h | 11 ++++++----- 1 file 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