mirror of
https://github.com/RsyncProject/rsync.git
synced 2026-05-18 20:06:07 -04:00
added msleep() function
This commit is contained in:
26
util.c
26
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>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user