summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2000-08-19 12:53:51 +0000
committerAndrew Tridgell <tridge@samba.org>2000-08-19 12:53:51 +0000
commit9ec16c83be3164bdcfe8412933d5b7fc86cabcb1 (patch)
tree8c6221db19256a531a78c28a1d80a7dddd3ad5db
parenta24c687094ca7da998065c33365f6ba1168cb44d (diff)
downloadrsync-9ec16c83be3164bdcfe8412933d5b7fc86cabcb1.tar.gz
added msleep() function
-rw-r--r--util.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/util.c b/util.c
index b9616963..bd0af33f 100644
--- a/util.c
+++ b/util.c
@@ -929,6 +929,32 @@ char *timestring(time_t t)
return(TimeBuf);
}
+
+/*******************************************************************
+sleep for a specified number of milliseconds
+********************************************************************/
+void msleep(int t)
+{
+ int tdiff=0;
+ struct timeval tval,t1,t2;
+
+ gettimeofday(&t1, NULL);
+ gettimeofday(&t2, NULL);
+
+ while (tdiff < t) {
+ tval.tv_sec = (t-tdiff)/1000;
+ tval.tv_usec = 1000*((t-tdiff)%1000);
+
+ errno = 0;
+ select(0,NULL,NULL, NULL, &tval);
+
+ gettimeofday(&t2, NULL);
+ tdiff = (t2.tv_sec - t1.tv_sec)*1000 +
+ (t2.tv_usec - t1.tv_usec)/1000;
+ }
+}
+
+
#ifdef __INSURE__
#include <dlfcn.h>