mirror of
https://github.com/samba-team/samba.git
synced 2024-12-24 21:34:56 +03:00
In msleep - never sleep for more than 1 second. Cope with time changes.
Jeremy.
(This used to be commit 9fb6a47526
)
This commit is contained in:
parent
94c52a0052
commit
752324ee1a
@ -627,26 +627,37 @@ SMB_OFF_T transfer_file(int infd,int outfd,SMB_OFF_T n)
|
||||
Sleep for a specified number of milliseconds.
|
||||
********************************************************************/
|
||||
|
||||
void msleep(int t)
|
||||
void msleep(unsigned int t)
|
||||
{
|
||||
int tdiff=0;
|
||||
struct timeval tval,t1,t2;
|
||||
fd_set fds;
|
||||
unsigned int tdiff=0;
|
||||
struct timeval tval,t1,t2;
|
||||
fd_set fds;
|
||||
|
||||
GetTimeOfDay(&t1);
|
||||
GetTimeOfDay(&t2);
|
||||
GetTimeOfDay(&t1);
|
||||
GetTimeOfDay(&t2);
|
||||
|
||||
while (tdiff < t) {
|
||||
tval.tv_sec = (t-tdiff)/1000;
|
||||
tval.tv_usec = 1000*((t-tdiff)%1000);
|
||||
|
||||
FD_ZERO(&fds);
|
||||
errno = 0;
|
||||
sys_select_intr(0,&fds,NULL,NULL,&tval);
|
||||
while (tdiff < t) {
|
||||
tval.tv_sec = (t-tdiff)/1000;
|
||||
tval.tv_usec = 1000*((t-tdiff)%1000);
|
||||
|
||||
GetTimeOfDay(&t2);
|
||||
tdiff = TvalDiff(&t1,&t2);
|
||||
}
|
||||
/* Never wait for more than 1 sec. */
|
||||
if (tval.tv_sec > 1) {
|
||||
tval.tv_sec = 1;
|
||||
tval.tv_usec = 0;
|
||||
}
|
||||
|
||||
FD_ZERO(&fds);
|
||||
errno = 0;
|
||||
sys_select_intr(0,&fds,NULL,NULL,&tval);
|
||||
|
||||
GetTimeOfDay(&t2);
|
||||
if (t2.tv_sec < t1.tv_sec) {
|
||||
/* Someone adjusted time... */
|
||||
t1 = t2;
|
||||
}
|
||||
|
||||
tdiff = TvalDiff(&t1,&t2);
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
|
Loading…
Reference in New Issue
Block a user