[SCM] Samba Shared Repository - branch master updated
Björn Jacke
bjacke at samba.org
Thu Sep 16 13:42:49 MDT 2010
The branch, master has been updated
via 6bc68fa s3: remove TvalDiff macro, we can use the shared usec_time_diff function
via 2b254c8 s3/s4: merge msleep and smb_msleep
via 0fd1601 s3: remove TspecDiff macro, we can use the shared nsec_time_diff function
via aada719 s3: use nsec_time_diff instead of TspecDiff
via ec643df s3/vfs_scannedonly: use smb_msleep instead of nanosleep
from 0858b75 s3: Add the PAC info3 struct to the netsamlogon_cache in ntlm_auth
http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master
- Log -----------------------------------------------------------------
commit 6bc68fabb81d019e017d7f51fdd0b275b3f78609
Author: Björn Jacke <bj at sernet.de>
Date: Thu Sep 16 21:36:00 2010 +0200
s3: remove TvalDiff macro, we can use the shared usec_time_diff function
commit 2b254c814b139f93997f61525d77b934596c53a3
Author: Björn Jacke <bj at sernet.de>
Date: Thu Sep 16 21:36:37 2010 +0200
s3/s4: merge msleep and smb_msleep
the merged variant is renamed to smb_msleep as some platforms already have a
msleep function.
commit 0fd16018a1c993166eae72390433398347538a81
Author: Björn Jacke <bj at sernet.de>
Date: Thu Sep 16 19:45:43 2010 +0200
s3: remove TspecDiff macro, we can use the shared nsec_time_diff function
commit aada7196940377ca6942eed470fc2e0e42f71b32
Author: Björn Jacke <bj at sernet.de>
Date: Thu Sep 16 19:02:27 2010 +0200
s3: use nsec_time_diff instead of TspecDiff
commit ec643df212e521fc19119820b1e4fac15986bf28
Author: Björn Jacke <bj at sernet.de>
Date: Thu Sep 16 18:52:45 2010 +0200
s3/vfs_scannedonly: use smb_msleep instead of nanosleep
Thanks to Joachim Schmitz. This fixes bug #7478
-----------------------------------------------------------------------
Summary of changes:
lib/util/util.c | 49 +++++++++++--
lib/util/util.h | 2 +-
source3/client/client.c | 4 +-
source3/include/smb_macros.h | 18 -----
source3/lib/util.c | 49 ------------
source3/libsmb/namequery.c | 4 +-
source3/modules/vfs_scannedonly.c | 3 +-
source4/torture/basic/base.c | 4 +-
source4/torture/basic/delaywrite.c | 132 ++++++++++++++++----------------
source4/torture/basic/delete.c | 2 +-
source4/torture/basic/disconnect.c | 2 +-
source4/torture/gentest.c | 2 +-
source4/torture/nbench/nbio.c | 4 +-
source4/torture/nbt/winsreplication.c | 4 +-
source4/torture/raw/notify.c | 8 +-
source4/torture/rpc/handles.c | 6 +-
source4/torture/rpc/lsa.c | 2 +-
source4/torture/rpc/netlogon.c | 10 +-
source4/torture/smb2/lease.c | 2 +-
source4/torture/smb2/notify.c | 8 +-
source4/torture/util_smb.c | 4 +-
21 files changed, 143 insertions(+), 176 deletions(-)
Changeset truncated at 500 lines:
diff --git a/lib/util/util.c b/lib/util/util.c
index 076ddf4..296a2a6 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 994fad0..c613e65 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/client/client.c b/source3/client/client.c
index c911559..cb9ba24 100644
--- a/source3/client/client.c
+++ b/source3/client/client.c
@@ -1119,7 +1119,7 @@ static int do_get(const char *rname, const char *lname_in, bool reget)
int this_time;
clock_gettime_mono(&tp_end);
- this_time = TspecDiff(&tp_start,&tp_end);
+ this_time = nsec_time_diff(&tp_start,&tp_end)/1000000;
get_total_time_ms += this_time;
get_total_size += nread;
@@ -1768,7 +1768,7 @@ static int do_put(const char *rname, const char *lname, bool reput)
int this_time;
clock_gettime_mono(&tp_end);
- this_time = TspecDiff(&tp_start,&tp_end);
+ this_time = nsec_time_diff(&tp_start,&tp_end)/1000000;
put_total_time_ms += this_time;
put_total_size += state.nread;
diff --git a/source3/include/smb_macros.h b/source3/include/smb_macros.h
index e72f2aa..9f4b345 100644
--- a/source3/include/smb_macros.h
+++ b/source3/include/smb_macros.h
@@ -144,24 +144,6 @@
#define ENCRYPTION_REQUIRED(conn) ((conn) ? ((conn)->encrypt_level == Required) : false)
#define IS_CONN_ENCRYPTED(conn) ((conn) ? (conn)->encrypted_tid : false)
-/*******************************************************************
-find the difference in milliseconds between two struct timeval
-values
-********************************************************************/
-
-#define TvalDiff(tvalold,tvalnew) \
- (((tvalnew)->tv_sec - (tvalold)->tv_sec)*1000 + \
- ((int)(tvalnew)->tv_usec - (int)(tvalold)->tv_usec)/1000)
-
-/*******************************************************************
-find the difference in milliseconds between two struct timespec
-values
-********************************************************************/
-
-#define TspecDiff(tvalold,tvalnew) \
- (((tvalnew)->tv_sec - (tvalold)->tv_sec)*1000 + \
- ((int)(tvalnew)->tv_nsec - (int)(tvalold)->tv_nsec)/1000000)
-
/****************************************************************************
true if two IPv4 addresses are equal
****************************************************************************/
diff --git a/source3/lib/util.c b/source3/lib/util.c
index 3303894..fab622b 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/source3/libsmb/namequery.c b/source3/libsmb/namequery.c
index c949d3b..00a3b97 100644
--- a/source3/libsmb/namequery.c
+++ b/source3/libsmb/namequery.c
@@ -307,7 +307,7 @@ NODE_STATUS_STRUCT *node_status_query(int fd,
while (1) {
struct timespec tp2;
clock_gettime_mono(&tp2);
- if (TspecDiff(&tp,&tp2) > retry_time) {
+ if (nsec_time_diff(&tp,&tp2)/1000000 > retry_time) {
if (!retries)
break;
if (!found && !send_packet(&p))
@@ -716,7 +716,7 @@ struct sockaddr_storage *name_query(int fd,
struct timespec tp2;
clock_gettime_mono(&tp2);
- if (TspecDiff(&tp,&tp2) > retry_time) {
+ if (nsec_time_diff(&tp,&tp2)/1000000 > retry_time) {
if (!retries)
break;
if (!found && !send_packet(&p))
diff --git a/source3/modules/vfs_scannedonly.c b/source3/modules/vfs_scannedonly.c
index b76bef4..ab5a7f4 100644
--- a/source3/modules/vfs_scannedonly.c
+++ b/source3/modules/vfs_scannedonly.c
@@ -476,13 +476,12 @@ static bool scannedonly_allow_access(vfs_handle_struct * handle,
flush_sendbuffer(handle);
while (retval != 0 /*&& errno == ENOENT */
&& i < recheck_tries) {
- struct timespec req = { 0, recheck_time * 10000 };
DEBUG(SCANNEDONLY_DEBUG,
("scannedonly_allow_access, wait (try=%d "
"(max %d), %d ms) for %s\n",
i, recheck_tries,
recheck_time, cache_smb_fname->base_name));
- nanosleep(&req, NULL);
+ smb_msleep(recheck_time);
retval = SMB_VFS_NEXT_STAT(handle, cache_smb_fname);
i++;
}
diff --git a/source4/torture/basic/base.c b/source4/torture/basic/base.c
index c9148d1..7b96e1c 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 0c43c29..f82b32f 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);
--
Samba Shared Repository
More information about the samba-cvs
mailing list