diff --git a/src/thread/thread.c b/src/thread/thread.c index 26038b14..c9814c68 100644 --- a/src/thread/thread.c +++ b/src/thread/thread.c @@ -568,7 +568,7 @@ void thread_sleep(unsigned long len) struct timeval tv; tv.tv_sec = len / 1000000; - tv.tv_usec = (len % 1000000) / 1000; + tv.tv_usec = (len % 1000000); select(0, NULL, NULL, NULL, &tv); # endif diff --git a/src/util.c b/src/util.c index b4ff7a71..5db20516 100644 --- a/src/util.c +++ b/src/util.c @@ -60,7 +60,7 @@ int util_timed_wait_for_fd(int fd, int timeout) FD_SET(fd, &rfds); tv.tv_sec = timeout/1000; - tv.tv_usec = (timeout - tv.tv_sec)*1000; + tv.tv_usec = (timeout % 1000)*1000; return select(fd+1, &rfds, NULL, NULL, &tv); #endif