s3/s4: merge msleep and smb_msleep
authorBjörn Jacke <bj@sernet.de>
Thu, 16 Sep 2010 19:36:37 +0000 (21:36 +0200)
committerBjörn Jacke <bj@sernet.de>
Thu, 16 Sep 2010 19:38:20 +0000 (21:38 +0200)
the merged variant is renamed to smb_msleep as some platforms already have a
msleep function.

17 files changed:
lib/util/util.c
lib/util/util.h
source3/lib/util.c
source4/torture/basic/base.c
source4/torture/basic/delaywrite.c
source4/torture/basic/delete.c
source4/torture/basic/disconnect.c
source4/torture/gentest.c
source4/torture/nbench/nbio.c
source4/torture/nbt/winsreplication.c
source4/torture/raw/notify.c
source4/torture/rpc/handles.c
source4/torture/rpc/lsa.c
source4/torture/rpc/netlogon.c
source4/torture/smb2/lease.c
source4/torture/smb2/notify.c
source4/torture/util_smb.c

index 076ddf47fc5e4458fd3959e1586940e14206e243..296a2a6c68e7117f95e87647fd05ac306c6497a6 100644 (file)
@@ -165,15 +165,50 @@ _PUBLIC_ bool directory_create_or_exist(const char *dname, uid_t uid,
  Sleep for a specified number of milliseconds.
 **/
 
-_PUBLIC_ void msleep(unsigned int t)
+_PUBLIC_ void smb_msleep(unsigned int t)
 {
-       struct timeval tval;  
+#if defined(HAVE_NANOSLEEP)
+       struct timespec ts;
+       int ret;
+
+       ts.tv_sec = t/1000;
+       ts.tv_nsec = 1000000*(t%1000);
+
+       do {
+               errno = 0;
+               ret = nanosleep(&ts, &ts);
+       } while (ret < 0 && errno == EINTR && (ts.tv_sec > 0 || ts.tv_nsec > 0));
+#else
+       unsigned int tdiff=0;
+       struct timeval tval,t1,t2;
+       fd_set fds;
 
-       tval.tv_sec = t/1000;
-       tval.tv_usec = 1000*(t%1000);
-       /* this should be the real select - do NOT replace
-          with sys_select() */
-       select(0,NULL,NULL,NULL,&tval);
+       GetTimeOfDay(&t1);
+       t2 = t1;
+
+       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;
+               }
+
+               FD_ZERO(&fds);
+               errno = 0;
+               select(0,&fds,NULL,NULL,&tval);
+
+               GetTimeOfDay(&t2);
+               if (t2.tv_sec < t1.tv_sec) {
+                       /* Someone adjusted time... */
+                       t1 = t2;
+               }
+
+               tdiff = usec_time_diff(&t1,&t2)/1000;
+       }
+#endif
 }
 
 /**
index 994fad04d3b12b2ac7cea7e30708e46ce236657f..c613e65adf93fca9186719fb8b86398024e56f59 100644 (file)
@@ -655,7 +655,7 @@ _PUBLIC_ int set_blocking(int fd, bool set);
 /**
  Sleep for a specified number of milliseconds.
 **/
-_PUBLIC_ void msleep(unsigned int t);
+_PUBLIC_ void smb_msleep(unsigned int t);
 
 /**
  Get my own name, return in talloc'ed storage.
index 3303894e0e50c7b807de90ed9dc435422ef4c88e..fab622b4e14f89756ce5d26b415fc1d5ca19037a 100644 (file)
@@ -823,55 +823,6 @@ ssize_t write_data_at_offset(int fd, const char *buffer, size_t N, SMB_OFF_T pos
 #endif
 }
 
-/*******************************************************************
- Sleep for a specified number of milliseconds.
-********************************************************************/
-
-void smb_msleep(unsigned int t)
-{
-#if defined(HAVE_NANOSLEEP)
-       struct timespec tval;
-       int ret;
-
-       tval.tv_sec = t/1000;
-       tval.tv_nsec = 1000000*(t%1000);
-
-       do {
-               errno = 0;
-               ret = nanosleep(&tval, &tval);
-       } while (ret < 0 && errno == EINTR && (tval.tv_sec > 0 || tval.tv_nsec > 0));
-#else
-       unsigned int tdiff=0;
-       struct timeval tval,t1,t2;  
-       fd_set fds;
-
-       GetTimeOfDay(&t1);
-       t2 = t1;
-
-       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;
-               }
-
-               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);
-       }
-#endif
-}
 
 NTSTATUS reinit_after_fork(struct messaging_context *msg_ctx,
                           struct event_context *ev_ctx,
index c9148d1915ab64c4dd0009006ebd8ed7756b9135..7b96e1c093739fbee67b34d857e74a15e17fb627 100644 (file)
@@ -680,13 +680,13 @@ static bool run_deferopen(struct torture_context *tctx, struct smbcli_state *cli
 
                torture_comment(tctx, "pid %u open %d\n", (unsigned)getpid(), i);
 
-               msleep(10 * msec);
+               smb_msleep(10 * msec);
                i++;
                if (NT_STATUS_IS_ERR(smbcli_close(cli->tree, fnum))) {
                        torture_comment(tctx,"Failed to close %s, error=%s\n", fname, smbcli_errstr(cli->tree));
                        return false;
                }
-               msleep(2 * msec);
+               smb_msleep(2 * msec);
        }
 
        if (NT_STATUS_IS_ERR(smbcli_unlink(cli->tree, fname))) {
index 0c43c29cade006c6fbe84e19169f311e9ed336ce..f82b32fe8db735b814cb05e3a1b31e725d1303f5 100644 (file)
@@ -111,7 +111,7 @@ static bool test_delayed_write_update(struct torture_context *tctx, struct smbcl
                        break;
                }
                fflush(stdout);
-               msleep(1 * msec);
+               smb_msleep(1 * msec);
        }
        
        if (finfo1.basic_info.out.write_time == finfo2.basic_info.out.write_time) {
@@ -162,7 +162,7 @@ static bool test_delayed_write_update1(struct torture_context *tctx, struct smbc
 
        /* 3 second delay to ensure we get past any 2 second time
           granularity (older systems may have that) */
-       msleep(3 * msec);
+       smb_msleep(3 * msec);
 
        finfo1.all_info.level = RAW_FILEINFO_ALL_INFO;
        finfo1.all_info.in.file.fnum = fnum1;
@@ -180,7 +180,7 @@ static bool test_delayed_write_update1(struct torture_context *tctx, struct smbc
 
        /* 3 second delay to ensure we get past any 2 second time
           granularity (older systems may have that) */
-       msleep(3 * msec);
+       smb_msleep(3 * msec);
 
        /* Do a zero length SMBwrite call to truncate. */
        written = smbcli_smbwrite(cli->tree, fnum1, "x", 1024, 0);
@@ -231,7 +231,7 @@ static bool test_delayed_write_update1(struct torture_context *tctx, struct smbc
                        break;
                }
                fflush(stdout);
-               msleep(1 * msec);
+               smb_msleep(1 * msec);
        }
 
        if (finfo1.all_info.out.write_time == finfo2.all_info.out.write_time) {
@@ -241,7 +241,7 @@ static bool test_delayed_write_update1(struct torture_context *tctx, struct smbc
        }
 
        fflush(stdout);
-       msleep(2 * msec);
+       smb_msleep(2 * msec);
 
        /* Do a non-zero length SMBwrite and make sure it doesn't update the write time. */
        written = smbcli_smbwrite(cli->tree, fnum1, "x", 0, 1);
@@ -282,7 +282,7 @@ static bool test_delayed_write_update1(struct torture_context *tctx, struct smbc
                        break;
                }
                fflush(stdout);
-               msleep(1 * msec);
+               smb_msleep(1 * msec);
        }
 
        if (finfo2.all_info.out.write_time != finfo3.all_info.out.write_time) {
@@ -292,7 +292,7 @@ static bool test_delayed_write_update1(struct torture_context *tctx, struct smbc
        }
 
        fflush(stdout);
-       msleep(2 * msec);
+       smb_msleep(2 * msec);
 
        /* the close should trigger an write time update */
        smbcli_close(cli->tree, fnum1);
@@ -353,7 +353,7 @@ static bool test_delayed_write_update1a(struct torture_context *tctx, struct smb
 
        /* 3 second delay to ensure we get past any 2 second time
           granularity (older systems may have that) */
-       msleep(3 * msec);
+       smb_msleep(3 * msec);
 
        finfo1.all_info.level = RAW_FILEINFO_ALL_INFO;
        finfo1.all_info.in.file.fnum = fnum1;
@@ -418,7 +418,7 @@ static bool test_delayed_write_update1a(struct torture_context *tctx, struct smb
                        break;
                }
                fflush(stdout);
-               msleep(1 * msec);
+               smb_msleep(1 * msec);
        }
 
        if (finfo1.all_info.out.write_time == finfo2.all_info.out.write_time) {
@@ -428,7 +428,7 @@ static bool test_delayed_write_update1a(struct torture_context *tctx, struct smb
        }
 
        fflush(stdout);
-       msleep(2 * msec);
+       smb_msleep(2 * msec);
 
        /* Do a non-zero length SMBwrite and make sure it doesn't update the write time. */
        written = smbcli_smbwrite(cli->tree, fnum1, "x", 0, 1);
@@ -467,7 +467,7 @@ static bool test_delayed_write_update1a(struct torture_context *tctx, struct smb
                        break;
                }
                fflush(stdout);
-               msleep(1 * msec);
+               smb_msleep(1 * msec);
        }
 
        if (finfo2.all_info.out.write_time != finfo3.all_info.out.write_time) {
@@ -535,7 +535,7 @@ static bool test_delayed_write_update1b(struct torture_context *tctx, struct smb
 
        /* 3 second delay to ensure we get past any 2 second time
           granularity (older systems may have that) */
-       msleep(3 * msec);
+       smb_msleep(3 * msec);
 
        finfo1.all_info.level = RAW_FILEINFO_ALL_INFO;
        finfo1.all_info.in.file.fnum = fnum1;
@@ -596,7 +596,7 @@ static bool test_delayed_write_update1b(struct torture_context *tctx, struct smb
                        break;
                }
                fflush(stdout);
-               msleep(1 * msec);
+               smb_msleep(1 * msec);
        }
 
        if (finfo1.all_info.out.write_time == finfo2.all_info.out.write_time) {
@@ -606,7 +606,7 @@ static bool test_delayed_write_update1b(struct torture_context *tctx, struct smb
        }
 
        fflush(stdout);
-       msleep(2 * msec);
+       smb_msleep(2 * msec);
 
        /* Do a non-zero length SMBwrite and make sure it doesn't update the write time. */
        written = smbcli_smbwrite(cli->tree, fnum1, "x", 0, 1);
@@ -644,7 +644,7 @@ static bool test_delayed_write_update1b(struct torture_context *tctx, struct smb
                        break;
                }
                fflush(stdout);
-               msleep(1 * msec);
+               smb_msleep(1 * msec);
        }
 
        if (finfo2.all_info.out.write_time != finfo3.all_info.out.write_time) {
@@ -710,7 +710,7 @@ static bool test_delayed_write_update1c(struct torture_context *tctx, struct smb
 
        /* 3 second delay to ensure we get past any 2 second time
           granularity (older systems may have that) */
-       msleep(3 * msec);
+       smb_msleep(3 * msec);
 
        finfo1.all_info.level = RAW_FILEINFO_ALL_INFO;
        finfo1.all_info.in.file.fnum = fnum1;
@@ -776,7 +776,7 @@ static bool test_delayed_write_update1c(struct torture_context *tctx, struct smb
                        break;
                }
                fflush(stdout);
-               msleep(1 * msec);
+               smb_msleep(1 * msec);
        }
 
        if (finfo1.all_info.out.write_time == finfo2.all_info.out.write_time) {
@@ -786,7 +786,7 @@ static bool test_delayed_write_update1c(struct torture_context *tctx, struct smb
        }
 
        fflush(stdout);
-       msleep(2 * msec);
+       smb_msleep(2 * msec);
 
        /* Do a non-zero length SMBwrite and make sure it doesn't update the write time. */
        written = smbcli_smbwrite(cli->tree, fnum1, "x", 0, 1);
@@ -822,7 +822,7 @@ static bool test_delayed_write_update1c(struct torture_context *tctx, struct smb
                        break;
                }
                fflush(stdout);
-               msleep(1 * msec);
+               smb_msleep(1 * msec);
        }
 
        if (finfo2.all_info.out.write_time != finfo3.all_info.out.write_time) {
@@ -900,7 +900,7 @@ static bool test_delayed_write_update2(struct torture_context *tctx, struct smbc
 
        /* 3 second delay to ensure we get past any 2 second time
           granularity (older systems may have that) */
-       msleep(3 * msec);
+       smb_msleep(3 * msec);
 
        {
                /* Try using setfileinfo instead of write to update write time. */
@@ -1007,7 +1007,7 @@ static bool test_delayed_write_update2(struct torture_context *tctx, struct smbc
                        break;
                }
                fflush(stdout);
-               msleep(1 * msec);
+               smb_msleep(1 * msec);
        }
        
        if (finfo1.basic_info.out.write_time == finfo2.basic_info.out.write_time) {
@@ -1015,7 +1015,7 @@ static bool test_delayed_write_update2(struct torture_context *tctx, struct smbc
        }
 
        fflush(stdout);
-       msleep(2 * msec);
+       smb_msleep(2 * msec);
 
        fnum2 = smbcli_open(cli->tree, fname, O_RDWR, DENY_NONE);
        if (fnum2 == -1) {
@@ -1099,7 +1099,7 @@ static bool test_delayed_write_update2(struct torture_context *tctx, struct smbc
                        break;
                }
                fflush(stdout);
-               msleep(1 * msec);
+               smb_msleep(1 * msec);
        }
        
        if (finfo1.basic_info.out.write_time == finfo2.basic_info.out.write_time) {
@@ -1131,7 +1131,7 @@ static bool test_delayed_write_update2(struct torture_context *tctx, struct smbc
        torture_comment(tctx, "Second open initial write time %s\n", 
               nt_time_string(tctx, finfo1.basic_info.out.write_time));
 
-       msleep(10 * msec);
+       smb_msleep(10 * msec);
        torture_comment(tctx, "Doing a 10 byte write to extend the file to see if this changes the last write time.\n");
 
        written =  smbcli_write(cli->tree, fnum1, 0, "0123456789", 31, 10);
@@ -1187,7 +1187,7 @@ static bool test_delayed_write_update2(struct torture_context *tctx, struct smbc
                        break;
                }
                fflush(stdout);
-               msleep(1*msec);
+               smb_msleep(1*msec);
        }
        
        if (finfo1.basic_info.out.write_time == finfo2.basic_info.out.write_time) {
@@ -1258,7 +1258,7 @@ static bool test_finfo_after_write(struct torture_context *tctx, struct smbcli_s
                goto done;
        }
 
-       msleep(1 * msec);
+       smb_msleep(1 * msec);
 
        written =  smbcli_write(cli->tree, fnum1, 0, "x", 0, 1);
 
@@ -1573,7 +1573,7 @@ static bool test_delayed_write_update3(struct torture_context *tctx,
                                        diff, sec);
                        break;
                }
-               msleep(0.5 * msec);
+               smb_msleep(0.5 * msec);
        }
 
        GET_INFO_BOTH(finfo1,pinfo1);
@@ -1602,7 +1602,7 @@ static bool test_delayed_write_update3(struct torture_context *tctx,
                        ret = false;
                        break;
                }
-               msleep(1 * msec);
+               smb_msleep(1 * msec);
        }
 
        GET_INFO_BOTH(finfo2,pinfo2);
@@ -1612,7 +1612,7 @@ static bool test_delayed_write_update3(struct torture_context *tctx,
        }
 
        /* sleep */
-       msleep(5 * msec);
+       smb_msleep(5 * msec);
 
        GET_INFO_BOTH(finfo3,pinfo3);
        COMPARE_WRITE_TIME_EQUAL(finfo3, finfo2);
@@ -1699,7 +1699,7 @@ static bool test_delayed_write_update3a(struct torture_context *tctx,
         * sleep some time, to demonstrate the handling of write times
         * doesn't depend on the time since the open
         */
-       msleep(5 * msec);
+       smb_msleep(5 * msec);
 
        /* get the initial times */
        GET_INFO_BOTH(finfo1,pinfo1);
@@ -1739,20 +1739,20 @@ static bool test_delayed_write_update3a(struct torture_context *tctx,
                                        diff, sec);
                        break;
                }
-               msleep(0.5 * msec);
+               smb_msleep(0.5 * msec);
        }
 
        GET_INFO_BOTH(finfo1,pinfo1);
        COMPARE_WRITE_TIME_GREATER(pinfo1, pinfo0);
 
-       msleep(3 * msec);
+       smb_msleep(3 * msec);
 
        /*
         * demonstrate that a truncate write always
         * updates the write time immediately
         */
        for (i=0; i < 3; i++) {
-               msleep(2 * msec);
+               smb_msleep(2 * msec);
                /* do a write */
                torture_comment(tctx, "Do a truncate SMBwrite [%d] on the file handle\n", i);
                written = smbcli_smbwrite(cli->tree, fnum1, "x", 10240, 0);
@@ -1767,7 +1767,7 @@ static bool test_delayed_write_update3a(struct torture_context *tctx,
                finfo1 = finfo2;
        }
 
-       msleep(3 * msec);
+       smb_msleep(3 * msec);
 
        /* sure any further write doesn't update the write time */
        start = timeval_current();
@@ -1792,7 +1792,7 @@ static bool test_delayed_write_update3a(struct torture_context *tctx,
                        ret = false;
                        break;
                }
-               msleep(1 * msec);
+               smb_msleep(1 * msec);
        }
 
        GET_INFO_BOTH(finfo2,pinfo2);
@@ -1802,7 +1802,7 @@ static bool test_delayed_write_update3a(struct torture_context *tctx,
        }
 
        /* sleep */
-       msleep(3 * msec);
+       smb_msleep(3 * msec);
 
        /* get the initial times */
        GET_INFO_BOTH(finfo1,pinfo1);
@@ -1813,7 +1813,7 @@ static bool test_delayed_write_update3a(struct torture_context *tctx,
         * updates the write time immediately
         */
        for (i=0; i < 3; i++) {
-               msleep(2 * msec);
+               smb_msleep(2 * msec);
                /* do a write */
                torture_comment(tctx, "Do a truncate SMBwrite [%d] on the file handle\n", i);
                written = smbcli_smbwrite(cli->tree, fnum1, "x", 512, 0);
@@ -1829,7 +1829,7 @@ static bool test_delayed_write_update3a(struct torture_context *tctx,
        }
 
        /* sleep */
-       msleep(3 * msec);
+       smb_msleep(3 * msec);
 
        GET_INFO_BOTH(finfo3,pinfo3);
        COMPARE_WRITE_TIME_EQUAL(finfo3, finfo2);
@@ -1914,7 +1914,7 @@ static bool test_delayed_write_update3b(struct torture_context *tctx,
         * sleep some time, to demonstrate the handling of write times
         * doesn't depend on the time since the open
         */
-       msleep(5 * msec);
+       smb_msleep(5 * msec);
 
        /* get the initial times */
        GET_INFO_BOTH(finfo1,pinfo1);
@@ -1954,7 +1954,7 @@ static bool test_delayed_write_update3b(struct torture_context *tctx,
                                        diff, sec);
                        break;
                }
-               msleep(0.5 * msec);
+               smb_msleep(0.5 * msec);
        }
 
        GET_INFO_BOTH(finfo1,pinfo1);
@@ -1983,7 +1983,7 @@ static bool test_delayed_write_update3b(struct torture_context *tctx,
                        ret = false;
                        break;
                }
-               msleep(1 * msec);
+               smb_msleep(1 * msec);
        }
 
        GET_INFO_BOTH(finfo2,pinfo2);
@@ -1993,7 +1993,7 @@ static bool test_delayed_write_update3b(struct torture_context *tctx,
        }
 
        /* sleep */
-       msleep(5 * msec);
+       smb_msleep(5 * msec);
 
        GET_INFO_BOTH(finfo3,pinfo3);
        COMPARE_WRITE_TIME_EQUAL(finfo3, finfo2);
@@ -2082,7 +2082,7 @@ static bool test_delayed_write_update3c(struct torture_context *tctx,
         * sleep some time, to demonstrate the handling of write times
         * doesn't depend on the time since the open
         */
-       msleep(5 * msec);
+       smb_msleep(5 * msec);
 
        /* get the initial times */
        GET_INFO_BOTH(finfo1,pinfo1);
@@ -2093,7 +2093,7 @@ static bool test_delayed_write_update3c(struct torture_context *tctx,
         * updates the write time immediately
         */
        for (i=0; i < 3; i++) {
-               msleep(2 * msec);
+               smb_msleep(2 * msec);
                /* do a write */
                torture_comment(tctx, "Do a truncate SMBwrite [%d] on the file handle\n", i);
                written = smbcli_smbwrite(cli->tree, fnum1, "x", 512, 0);
@@ -2130,7 +2130,7 @@ static bool test_delayed_write_update3c(struct torture_context *tctx,
                        ret = false;
                        break;
                }
-               msleep(1 * msec);
+               smb_msleep(1 * msec);
        }
 
        GET_INFO_BOTH(finfo2,pinfo2);
@@ -2140,7 +2140,7 @@ static bool test_delayed_write_update3c(struct torture_context *tctx,
        }
 
        /* sleep */
-       msleep(5 * msec);
+       smb_msleep(5 * msec);
 
        /* get the initial times */
        GET_INFO_BOTH(finfo1,pinfo1);
@@ -2151,7 +2151,7 @@ static bool test_delayed_write_update3c(struct torture_context *tctx,
         * updates the write time immediately
         */
        for (i=0; i < 3; i++) {
-               msleep(2 * msec);
+               smb_msleep(2 * msec);
                /* do a write */
                torture_comment(tctx, "Do a truncate write [%d] on the file handle\n", i);
                written = smbcli_smbwrite(cli->tree, fnum1, "x", 512, 0);
@@ -2167,7 +2167,7 @@ static bool test_delayed_write_update3c(struct torture_context *tctx,
        }
 
        /* sleep */
-       msleep(5 * msec);
+       smb_msleep(5 * msec);
 
        GET_INFO_BOTH(finfo2,pinfo2);
        COMPARE_WRITE_TIME_EQUAL(finfo2, finfo1);
@@ -2195,7 +2195,7 @@ static bool test_delayed_write_update3c(struct torture_context *tctx,
                        ret = false;
                        break;
                }
-               msleep(1 * msec);
+               smb_msleep(1 * msec);
        }
 
        GET_INFO_BOTH(finfo2,pinfo2);
@@ -2205,7 +2205,7 @@ static bool test_delayed_write_update3c(struct torture_context *tctx,
        }
 
        /* sleep */
-       msleep(5 * msec);
+       smb_msleep(5 * msec);
 
        GET_INFO_BOTH(finfo3,pinfo3);
        COMPARE_WRITE_TIME_EQUAL(finfo3, finfo2);
@@ -2289,7 +2289,7 @@ static bool test_delayed_write_update4(struct torture_context *tctx,
        GET_INFO_BOTH(finfo0,pinfo0);
 
        /* sleep a bit */
-       msleep(5 * msec);
+       smb_msleep(5 * msec);
 
        /* do a write */
        torture_comment(tctx, "Do a write on the file handle\n");
@@ -2329,7 +2329,7 @@ static bool test_delayed_write_update4(struct torture_context *tctx,
                                        diff, sec);
                        break;
                }
-               msleep(0.5 * msec);
+               smb_msleep(0.5 * msec);
        }
 
        GET_INFO_BOTH(finfo1,pinfo1);
@@ -2358,7 +2358,7 @@ static bool test_delayed_write_update4(struct torture_context *tctx,
                        ret = false;
                        break;
                }
-               msleep(1 * msec);
+               smb_msleep(1 * msec);
        }
 
        GET_INFO_BOTH(finfo2,pinfo2);
@@ -2368,7 +2368,7 @@ static bool test_delayed_write_update4(struct torture_context *tctx,
        }
 
        /* sleep */
-       msleep(5 * msec);
+       smb_msleep(5 * msec);
 
        GET_INFO_BOTH(finfo3,pinfo3);
        COMPARE_WRITE_TIME_EQUAL(finfo3, finfo2);
@@ -2489,7 +2489,7 @@ static bool test_delayed_write_update5(struct torture_context *tctx,
                        ret = false;
                        break;
                }
-               msleep(1 * msec);
+               smb_msleep(1 * msec);
        }
 
        GET_INFO_BOTH(finfo3,pinfo3);
@@ -2521,7 +2521,7 @@ static bool test_delayed_write_update5(struct torture_context *tctx,
                        ret = false;
                        break;
                }
-               msleep(1 * msec);
+               smb_msleep(1 * msec);
        }
 
        GET_INFO_BOTH(finfo4,pinfo4);
@@ -2531,7 +2531,7 @@ static bool test_delayed_write_update5(struct torture_context *tctx,
        }
 
        /* sleep */
-       msleep(5 * msec);
+       smb_msleep(5 * msec);
 
        GET_INFO_BOTH(finfo5,pinfo5);
        COMPARE_WRITE_TIME_EQUAL(finfo5, finfo4);
@@ -2651,7 +2651,7 @@ static bool test_delayed_write_update5b(struct torture_context *tctx,
                        ret = false;
                        break;
                }
-               msleep(1 * msec);
+               smb_msleep(1 * msec);
        }
 
        GET_INFO_BOTH(finfo3,pinfo3);
@@ -2683,7 +2683,7 @@ static bool test_delayed_write_update5b(struct torture_context *tctx,
                        ret = false;
                        break;
                }
-               msleep(1 * msec);
+               smb_msleep(1 * msec);
        }
 
        GET_INFO_BOTH(finfo4,pinfo4);
@@ -2693,7 +2693,7 @@ static bool test_delayed_write_update5b(struct torture_context *tctx,
        }
 
        /* sleep */
-       msleep(5 * msec);
+       smb_msleep(5 * msec);
 
        GET_INFO_BOTH(finfo5,pinfo5);
        COMPARE_WRITE_TIME_EQUAL(finfo5, finfo4);
@@ -2830,7 +2830,7 @@ again:
                        ret = false;
                        break;
                }
-               msleep(1 * msec);
+               smb_msleep(1 * msec);
        }
 
        GET_INFO_BOTH(finfo3,pinfo3);
@@ -2862,7 +2862,7 @@ again:
                        ret = false;
                        break;
                }
-               msleep(1 * msec);
+               smb_msleep(1 * msec);
        }
 
        GET_INFO_BOTH(finfo4,pinfo4);
@@ -2872,7 +2872,7 @@ again:
        }
 
        /* sleep */
-       msleep(5 * msec);
+       smb_msleep(5 * msec);
 
        GET_INFO_BOTH(finfo5,pinfo5);
        COMPARE_WRITE_TIME_EQUAL(finfo5, finfo4);
@@ -2898,7 +2898,7 @@ again:
        COMPARE_WRITE_TIME_EQUAL(finfo5, pinfo6);
 
        /* See if we have lost the sticky write time on handle2 */
-       msleep(3 * msec);
+       smb_msleep(3 * msec);
        torture_comment(tctx, "Have we lost the sticky write time ?\n");
 
        /* Make sure any further normal write doesn't update the write time */
@@ -2925,7 +2925,7 @@ again:
                        ret = false;
                        break;
                }
-               msleep(1 * msec);
+               smb_msleep(1 * msec);
        }
 
        /* What about a truncate write ? */
@@ -2952,7 +2952,7 @@ again:
                        ret = false;
                        break;
                }
-               msleep(1 * msec);
+               smb_msleep(1 * msec);
        }
 
 
index 22d92193b901a7382000ace444b102edf8ede1d7..2b26b1e64a7cefa35c00b6c9484192e8eab54232 100644 (file)
@@ -1422,7 +1422,7 @@ static bool deltest21(struct torture_context *tctx)
 
        /* On slow build farm machines it might happen that they are not fast
         * enogh to delete the file for this test */
-       msleep(200);
+       smb_msleep(200);
 
        /* File should not be there. */
        fnum1 = smbcli_nt_create_full(cli1->tree, fname, 0, 
index 7f071178f47da230b6c40a50825daf8b6582df6d..2cfa72048ebf2a7863da7e516acf9b40ff949e38 100644 (file)
@@ -162,7 +162,7 @@ bool torture_disconnect(struct torture_context *torture)
                         * new process comes in. Try to get rid of the random
                         * failures in the build farm.
                         */
-                       msleep(200);
+                       smb_msleep(200);
                }
        }
 
index 4fc05df3f408c6eb039553516566f898c1653575..6f69460dc8a7305543a30fb99aca462b0d6a3535 100644 (file)
@@ -1211,7 +1211,7 @@ static void check_pending(void)
 {
        int i, j;
 
-       msleep(20);
+       smb_msleep(20);
 
        for (j=0;j<NINSTANCES;j++) {
                for (i=0;i<NSERVERS;i++) {
index fa8155e2c30307d7e3a3fa761eaffc59390d283a..ca186d007b28e7c43f64fb59442e2987d2ba8f38 100644 (file)
@@ -192,7 +192,7 @@ void nbio_target_rate(double rate)
 
        tdelay = (children[nbio_id].bytes - last_bytes)/(1.0e6*rate) - timeval_elapsed(&last_time);
        if (tdelay > 0) {
-               msleep(tdelay*1000);
+               smb_msleep(tdelay*1000);
        } else {
                children[nbio_id].max_latency = MAX(children[nbio_id].max_latency, -tdelay);
        }
@@ -210,7 +210,7 @@ void nbio_time_delay(double targett)
 {
        double elapsed = timeval_elapsed(&children[nbio_id].starttime);
        if (targett > elapsed) {
-               msleep(1000*(targett - elapsed));
+               smb_msleep(1000*(targett - elapsed));
        } else if (elapsed - targett > children[nbio_id].max_latency) {
                children[nbio_id].max_latency = MAX(elapsed - targett, children[nbio_id].max_latency);
        }
index a0d4c23ae7e78b0a03b0b5ede33a05e9d890aa49..caa2d33ede324a2524a478a2451a010de4591f39 100644 (file)
@@ -9599,7 +9599,7 @@ static void test_conflict_owned_active_vs_replica_handler_query(struct nbt_name_
        while (nbtsock->send_queue) {
                event_loop_once(nbtsock->event_ctx);
        }
-       msleep(1000);
+       smb_msleep(1000);
 
        rec->defend.timeout     = 0;
        rec->defend.ret         = true;
@@ -9656,7 +9656,7 @@ static void test_conflict_owned_active_vs_replica_handler_release(
        while (nbtsock->send_queue) {
                event_loop_once(nbtsock->event_ctx);
        }
-       msleep(1000);
+       smb_msleep(1000);
 
        rec->defend.timeout     = 0;
        rec->defend.ret         = true;
index 6fc005929cd7e7bb11583105760e8f049e9110dd..7ccdbd7c7644f79c3d9cb0de2a397aba24113494 100644 (file)
@@ -144,7 +144,7 @@ static bool test_notify_dir(struct smbcli_state *cli, struct smbcli_state *cli2,
        smbcli_rmdir(cli2->tree, BASEDIR "\\subdir-name");
        smbcli_mkdir(cli2->tree, BASEDIR "\\subdir-name");
        smbcli_rmdir(cli2->tree, BASEDIR "\\subdir-name");
-       msleep(200);
+       smb_msleep(200);
        req = smb_raw_changenotify_send(cli->tree, &notify);
        status = smb_raw_changenotify_recv(req, mem_ctx, &notify);
        CHECK_STATUS(status, NT_STATUS_OK);
@@ -365,7 +365,7 @@ static bool test_notify_recursive(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
 
        notify.nttrans.in.completion_filter = 0;
        notify.nttrans.in.recursive = true;
-       msleep(200);
+       smb_msleep(200);
        req1 = smb_raw_changenotify_send(cli->tree, &notify);
 
        smbcli_rmdir(cli->tree, BASEDIR "\\subdir-name\\subname1-r");
@@ -602,7 +602,7 @@ static bool test_notify_mask(struct smbcli_state *cli, struct torture_context *t
                notify.nttrans.in.completion_filter = (1<<i); \
                req = smb_raw_changenotify_send(cli->tree, &notify); \
                op \
-               msleep(200); smb_raw_ntcancel(req); \
+               smb_msleep(200); smb_raw_ntcancel(req); \
                status = smb_raw_changenotify_recv(req, tctx, &notify); \
                cleanup \
                smbcli_close(cli->tree, fnum); \
@@ -1420,7 +1420,7 @@ static bool test_notify_basedir(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
 
        /* set attribute on a file to assure we receive a notification */
        smbcli_setatr(cli->tree, BASEDIR "\\tname1", FILE_ATTRIBUTE_HIDDEN, 0);
-       msleep(200);
+       smb_msleep(200);
 
        /* check how many responses were given, expect only 1 for the file */
        status = smb_raw_changenotify_recv(req1, mem_ctx, &notify);
index f47789ae6044b52782d66cd035d3160f46ebc4c7..13357ac9475093aa9e4d52ffa5f9eda4b7e038ad 100644 (file)
@@ -287,7 +287,7 @@ static bool test_handles_lsa_shared(struct torture_context *torture)
        /* close first connection */
        torture_comment(torture, "disconnect p1\n");
        talloc_free(p1);
-       msleep(5);
+       smb_msleep(5);
 
        /*
         * and it's still available on p2,p3
@@ -327,7 +327,7 @@ static bool test_handles_lsa_shared(struct torture_context *torture)
        talloc_free(p2);
        talloc_free(p3);
        talloc_free(p4);
-       msleep(10);
+       smb_msleep(10);
 
        /*
         * now open p5
@@ -455,7 +455,7 @@ static bool test_handles_mixed_shared(struct torture_context *torture)
 
        talloc_free(p1);
        talloc_free(p2);
-       msleep(10);
+       smb_msleep(10);
 
        torture_comment(torture, "connect samr pipe3 - should fail\n");
        status = torture_rpc_connection_transport(torture, &p3, &ndr_table_samr,
index 9283fc3e31f6454ce05849dd9574cbf3b97974b2..a1ad9fde1db5a950ecfa8f7c1b622ad01b71b6f2 100644 (file)
@@ -1435,7 +1435,7 @@ static bool test_CreateSecret(struct dcerpc_pipe *p,
                r5.in.new_val->size = enc_key.length;
 
 
-               msleep(200);
+               smb_msleep(200);
                torture_comment(tctx, "Testing SetSecret (existing value should move to old)\n");
 
                torture_assert_ntstatus_ok(tctx, dcerpc_lsa_SetSecret_r(b, tctx, &r5),
index b83b050fb285a647882858b411264d1b4811bb17..c2eb8724624e9d5fc0a8cbf4824161aacc197db7 100644 (file)
@@ -2911,7 +2911,7 @@ static bool test_GetDomainInfo(struct torture_context *tctx,
        torture_assert_ntstatus_ok(tctx, r.out.result, "LogonGetDomainInfo failed");
        torture_assert(tctx, netlogon_creds_client_check(creds, &a.cred), "Credential chaining failed");
 
-       msleep(250);
+       smb_msleep(250);
 
        if (sam_ctx) {
                /* AD workstation infos entry check */
@@ -3000,7 +3000,7 @@ static bool test_GetDomainInfo(struct torture_context *tctx,
 
        torture_assert(tctx, netlogon_creds_client_check(creds, &a.cred), "Credential chaining failed");
 
-       msleep(250);
+       smb_msleep(250);
 
        if (sam_ctx) {
                /* AD workstation infos entry check */
@@ -3076,7 +3076,7 @@ static bool test_GetDomainInfo(struct torture_context *tctx,
        torture_assert_ntstatus_ok(tctx, r.out.result, "LogonGetDomainInfo failed");
        torture_assert(tctx, netlogon_creds_client_check(creds, &a.cred), "Credential chaining failed");
 
-       msleep(250);
+       smb_msleep(250);
 
        if (sam_ctx) {
                /* AD workstation infos entry check */
@@ -3147,7 +3147,7 @@ static bool test_GetDomainInfo(struct torture_context *tctx,
        torture_assert_ntstatus_ok(tctx, r.out.result, "LogonGetDomainInfo failed");
        torture_assert(tctx, netlogon_creds_client_check(creds, &a.cred), "Credential chaining failed");
 
-       msleep(250);
+       smb_msleep(250);
 
        /* Now the in/out DNS hostnames should be the same */
        torture_assert_str_equal(tctx,
@@ -3181,7 +3181,7 @@ static bool test_GetDomainInfo(struct torture_context *tctx,
        torture_assert_ntstatus_ok(tctx, r.out.result, "LogonGetDomainInfo failed");
        torture_assert(tctx, netlogon_creds_client_check(creds, &a.cred), "Credential chaining failed");
 
-       msleep(250);
+       smb_msleep(250);
 
        /* Checks "workstation flags" */
        torture_assert(tctx,
index 63285d40e02c2b83f53386115138220a6a6887d0..eda3b97eeab5ed7e7d3a4d10309fdf2dda9c78e9 100644 (file)
@@ -803,7 +803,7 @@ static bool test_lease_multibreak(struct torture_context *tctx,
        break_info.held_oplock_level = io.out.oplock_level;
 
        /* Sleep, use a write to clear the recv queue. */
-       msleep(250);
+       smb_msleep(250);
        ZERO_STRUCT(w);
        w.in.file.handle = h3;
        w.in.offset      = 0;
index 313ef6848f92bb17e8b72198766f1c221982a68a..0115cd04789ee7af1356197b71f0c07fef3e367d 100644 (file)
@@ -308,7 +308,7 @@ static bool torture_smb2_notify_dir(struct torture_context *torture,
        smb2_util_rmdir(tree2, fname);
        smb2_util_mkdir(tree2, fname);
        smb2_util_rmdir(tree2, fname);
-       msleep(200);
+       smb_msleep(200);
        req = smb2_notify_send(tree1, &(notify.smb2));
        status = smb2_notify_recv(req, torture, &(notify.smb2));
        CHECK_STATUS(status, NT_STATUS_OK);
@@ -603,7 +603,7 @@ static bool torture_smb2_notify_recursive(struct torture_context *torture,
 
        notify.smb2.in.completion_filter = 0;
        notify.smb2.in.recursive = true;
-       msleep(200);
+       smb_msleep(200);
        req1 = smb2_notify_send(tree1, &(notify.smb2));
 
        status = smb2_util_rmdir(tree2, BASEDIR "\\subdir-name\\subname1-r");
@@ -898,7 +898,7 @@ static bool torture_smb2_notify_mask(struct torture_context *torture,
                /* send the change notify request */ \
                req = smb2_notify_send(tree1, &(notify.smb2)); \
                op \
-               msleep(200); smb2_cancel(req); \
+               smb_msleep(200); smb2_cancel(req); \
                status = smb2_notify_recv(req, torture, &(notify.smb2)); \
                cleanup \
                smb2_util_close(tree1, h1); \
@@ -1775,7 +1775,7 @@ static bool torture_smb2_notify_basedir(struct torture_context *torture,
 
        /* set attribute on a file to assure we receive a notification */
        smb2_util_setatr(tree2, BASEDIR "\\tname1", FILE_ATTRIBUTE_HIDDEN);
-       msleep(200);
+       smb_msleep(200);
 
        /* check how many responses were given, expect only 1 for the file */
        status = smb2_notify_recv(req1, torture, &(notify.smb2));
index 8d5accd2dc025d3729517cf851e249e24096d87d..df2716f3160ef9bf4cbd9f93da9d825efd33252f 100644 (file)
@@ -699,7 +699,7 @@ double torture_create_procs(struct torture_context *tctx,
                                        printf("pid %d failed to start\n", (int)getpid());
                                        _exit(1);
                                }
-                               msleep(100);    
+                               smb_msleep(100);        
                        }
 
                        child_status[i] = getpid();
@@ -723,7 +723,7 @@ double torture_create_procs(struct torture_context *tctx,
                        if (child_status[i]) synccount++;
                }
                if (synccount == torture_nprocs) break;
-               msleep(100);
+               smb_msleep(100);
        } while (timeval_elapsed(&tv) < start_time_limit);
 
        if (synccount != torture_nprocs) {