From e423246e7faabc25b1948eae8ccac632db108549 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20P=C3=A9gouri=C3=A9-Gonnard?= Date: Fri, 21 Nov 2014 09:52:23 +0100 Subject: [PATCH] Fix net_usleep for durations greater than 1 second --- library/net.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/library/net.c b/library/net.c index 3f0e448ba..2c77138c4 100644 --- a/library/net.c +++ b/library/net.c @@ -496,12 +496,12 @@ int net_set_nonblock( int fd ) void net_usleep( unsigned long usec ) { struct timeval tv; - tv.tv_sec = 0; + tv.tv_sec = usec / 1000000; #if !defined(_WIN32) && ( defined(__unix__) || defined(__unix) || \ ( defined(__APPLE__) && defined(__MACH__) ) ) - tv.tv_usec = (suseconds_t) usec; + tv.tv_usec = (suseconds_t) usec % 1000000; #else - tv.tv_usec = usec; + tv.tv_usec = usec % 1000000; #endif select( 0, NULL, NULL, NULL, &tv ); }