diff options
author | Andrew Tridgell <tridge@samba.org> | 2000-08-19 12:53:51 +0000 |
---|---|---|
committer | Andrew Tridgell <tridge@samba.org> | 2000-08-19 12:53:51 +0000 |
commit | 9ec16c83be3164bdcfe8412933d5b7fc86cabcb1 (patch) | |
tree | 8c6221db19256a531a78c28a1d80a7dddd3ad5db | |
parent | a24c687094ca7da998065c33365f6ba1168cb44d (diff) | |
download | rsync-9ec16c83be3164bdcfe8412933d5b7fc86cabcb1.tar.gz |
added msleep() function
-rw-r--r-- | util.c | 26 |
1 files changed, 26 insertions, 0 deletions
@@ -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> |