]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Use nanosleep instead of usleep
authorAki Tuomi <cmouse@desteem.org>
Sat, 4 Oct 2014 11:00:18 +0000 (14:00 +0300)
committerAki Tuomi <cmouse@desteem.org>
Sat, 4 Oct 2014 11:00:18 +0000 (14:00 +0300)
pdns/unix_utility.cc

index e85e306144a8d635c263fac375540c62b516e461..c6530cc4c9eb078f6fb37abe9142ce31d8f51ff5 100644 (file)
@@ -119,7 +119,11 @@ unsigned int Utility::sleep(unsigned int sec)
 
 void Utility::usleep(unsigned long usec)
 {
-  ::usleep(usec);
+  struct timespec ts;
+  ts.tv_sec = usec / 1000000;
+  ts.tv_nsec = (usec % 1000000) * 1000;
+  // POSIX.1 recommends using nanosleep instead of usleep
+  ::nanosleep(&ts, NULL); 
 }