summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2002-03-27 00:39:26 +0000
committerJeremy Allison <jra@samba.org>2002-03-27 00:39:26 +0000
commit752324ee1a9f73d2de41dd76993af94f6be5a61e (patch)
tree21c21f10313b4326d8b8288f0b2085361185666d /source3
parent94c52a00525c55db83d48c0ef76c3eb12de0af2b (diff)
downloadsamba-752324ee1a9f73d2de41dd76993af94f6be5a61e.tar.gz
samba-752324ee1a9f73d2de41dd76993af94f6be5a61e.tar.bz2
samba-752324ee1a9f73d2de41dd76993af94f6be5a61e.zip
In msleep - never sleep for more than 1 second. Cope with time changes.
Jeremy. (This used to be commit 9fb6a475264f465e30a23c34b5c9266921d135d1)
Diffstat (limited to 'source3')
-rw-r--r--source3/lib/util.c43
1 files changed, 27 insertions, 16 deletions
diff --git a/source3/lib/util.c b/source3/lib/util.c
index a2f8c086e8..d8bc17221e 100644
--- a/source3/lib/util.c
+++ b/source3/lib/util.c
@@ -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);
+
+ /* Never wait for more than 1 sec. */
+ if (tval.tv_sec > 1) {
+ tval.tv_sec = 1;
+ tval.tv_usec = 0;
+ }
- GetTimeOfDay(&t2);
- tdiff = TvalDiff(&t1,&t2);
- }
+ 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);
+ }
}
/****************************************************************************