diff options
author | Björn Jacke <bj@sernet.de> | 2010-09-16 21:36:37 +0200 |
---|---|---|
committer | Björn Jacke <bj@sernet.de> | 2010-09-16 21:38:20 +0200 |
commit | 2b254c814b139f93997f61525d77b934596c53a3 (patch) | |
tree | 945897a1c52a9d6d8f5958f47b6c8b4a877d7164 | |
parent | 0fd16018a1c993166eae72390433398347538a81 (diff) | |
download | samba-2b254c814b139f93997f61525d77b934596c53a3.tar.gz samba-2b254c814b139f93997f61525d77b934596c53a3.tar.bz2 samba-2b254c814b139f93997f61525d77b934596c53a3.zip |
s3/s4: merge msleep and smb_msleep
the merged variant is renamed to smb_msleep as some platforms already have a
msleep function.
-rw-r--r-- | lib/util/util.c | 49 | ||||
-rw-r--r-- | lib/util/util.h | 2 | ||||
-rw-r--r-- | source3/lib/util.c | 49 | ||||
-rw-r--r-- | source4/torture/basic/base.c | 4 | ||||
-rw-r--r-- | source4/torture/basic/delaywrite.c | 132 | ||||
-rw-r--r-- | source4/torture/basic/delete.c | 2 | ||||
-rw-r--r-- | source4/torture/basic/disconnect.c | 2 | ||||
-rw-r--r-- | source4/torture/gentest.c | 2 | ||||
-rw-r--r-- | source4/torture/nbench/nbio.c | 4 | ||||
-rw-r--r-- | source4/torture/nbt/winsreplication.c | 4 | ||||
-rw-r--r-- | source4/torture/raw/notify.c | 8 | ||||
-rw-r--r-- | source4/torture/rpc/handles.c | 6 | ||||
-rw-r--r-- | source4/torture/rpc/lsa.c | 2 | ||||
-rw-r--r-- | source4/torture/rpc/netlogon.c | 10 | ||||
-rw-r--r-- | source4/torture/smb2/lease.c | 2 | ||||
-rw-r--r-- | source4/torture/smb2/notify.c | 8 | ||||
-rw-r--r-- | source4/torture/util_smb.c | 4 |
17 files changed, 138 insertions, 152 deletions
diff --git a/lib/util/util.c b/lib/util/util.c index 076ddf47fc..296a2a6c68 100644 --- a/lib/util/util.c +++ b/lib/util/util.c @@ -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 } /** diff --git a/lib/util/util.h b/lib/util/util.h index 994fad04d3..c613e65adf 100644 --- a/lib/util/util.h +++ b/lib/util/util.h @@ -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. diff --git a/source3/lib/util.c b/source3/lib/util.c index 3303894e0e..fab622b4e1 100644 --- a/source3/lib/util.c +++ b/source3/lib/util.c @@ -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, diff --git a/source4/torture/basic/base.c b/source4/torture/basic/base.c index c9148d1915..7b96e1c093 100644 --- a/source4/torture/basic/base.c +++ b/source4/torture/basic/base.c @@ -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))) { diff --git a/source4/torture/basic/delaywrite.c b/source4/torture/basic/delaywrite.c index 0c43c29cad..f82b32fe8d 100644 --- a/source4/torture/basic/delaywrite.c +++ b/source4/torture/basic/delaywrite.c @@ -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); } diff --git a/source4/torture/basic/delete.c b/source4/torture/basic/delete.c index 22d92193b9..2b26b1e64a 100644 --- a/source4/torture/basic/delete.c +++ b/source4/torture/basic/delete.c @@ -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, diff --git a/source4/torture/basic/disconnect.c b/source4/torture/basic/disconnect.c index 7f071178f4..2cfa72048e 100644 --- a/source4/torture/basic/disconnect.c +++ b/source4/torture/basic/disconnect.c @@ -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); } } diff --git a/source4/torture/gentest.c b/source4/torture/gentest.c index 4fc05df3f4..6f69460dc8 100644 --- a/source4/torture/gentest.c +++ b/source4/torture/gentest.c @@ -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++) { diff --git a/source4/torture/nbench/nbio.c b/source4/torture/nbench/nbio.c index fa8155e2c3..ca186d007b 100644 --- a/source4/torture/nbench/nbio.c +++ b/source4/torture/nbench/nbio.c @@ -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); } diff --git a/source4/torture/nbt/winsreplication.c b/source4/torture/nbt/winsreplication.c index a0d4c23ae7..caa2d33ede 100644 --- a/source4/torture/nbt/winsreplication.c +++ b/source4/torture/nbt/winsreplication.c @@ -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; diff --git a/source4/torture/raw/notify.c b/source4/torture/raw/notify.c index 6fc005929c..7ccdbd7c76 100644 --- a/source4/torture/raw/notify.c +++ b/source4/torture/raw/notify.c @@ -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, ¬ify); status = smb_raw_changenotify_recv(req, mem_ctx, ¬ify); 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, ¬ify); 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, ¬ify); \ op \ - msleep(200); smb_raw_ntcancel(req); \ + smb_msleep(200); smb_raw_ntcancel(req); \ status = smb_raw_changenotify_recv(req, tctx, ¬ify); \ 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, ¬ify); diff --git a/source4/torture/rpc/handles.c b/source4/torture/rpc/handles.c index f47789ae60..13357ac947 100644 --- a/source4/torture/rpc/handles.c +++ b/source4/torture/rpc/handles.c @@ -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, diff --git a/source4/torture/rpc/lsa.c b/source4/torture/rpc/lsa.c index 9283fc3e31..a1ad9fde1d 100644 --- a/source4/torture/rpc/lsa.c +++ b/source4/torture/rpc/lsa.c @@ -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), diff --git a/source4/torture/rpc/netlogon.c b/source4/torture/rpc/netlogon.c index b83b050fb2..c2eb872462 100644 --- a/source4/torture/rpc/netlogon.c +++ b/source4/torture/rpc/netlogon.c @@ -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, diff --git a/source4/torture/smb2/lease.c b/source4/torture/smb2/lease.c index 63285d40e0..eda3b97eea 100644 --- a/source4/torture/smb2/lease.c +++ b/source4/torture/smb2/lease.c @@ -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; diff --git a/source4/torture/smb2/notify.c b/source4/torture/smb2/notify.c index 313ef6848f..0115cd0478 100644 --- a/source4/torture/smb2/notify.c +++ b/source4/torture/smb2/notify.c @@ -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)); diff --git a/source4/torture/util_smb.c b/source4/torture/util_smb.c index 8d5accd2dc..df2716f316 100644 --- a/source4/torture/util_smb.c +++ b/source4/torture/util_smb.c @@ -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) { |